diff --git a/.cargo/audit.toml b/.cargo/audit.toml index 5dbd178b6..b74b63d26 100644 --- a/.cargo/audit.toml +++ b/.cargo/audit.toml @@ -4,8 +4,4 @@ ignore = [ # chrono dependency, but vulnerable function is never called # Tacked in #3163 "RUSTSEC-2020-0071", - # chrono: Potential segfault in localtime_r invocations - # starship avoids setting any environment variables to avoid this issue - # Tracked in #3166 - "RUSTSEC-2020-0159", ] diff --git a/Cargo.lock b/Cargo.lock index 1c186a261..62365bc2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" version = "0.7.6" @@ -37,6 +43,18 @@ version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704" +[[package]] +name = "arc-swap" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "983cd8b9d4b02a6dc6ffa557262eb5858a27a0038ffffe21a0f133eaa819a164" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + [[package]] name = "async-broadcast" version = "0.4.0" @@ -46,7 +64,7 @@ dependencies = [ "easy-parallel", "event-listener", "futures-core", - "parking_lot", + "parking_lot 0.11.2", ] [[package]] @@ -130,6 +148,15 @@ dependencies = [ "syn", ] +[[package]] +name = "atoi" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e" +dependencies = [ + "num-traits", +] + [[package]] name = "atty" version = "0.2.14" @@ -165,25 +192,13 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array 0.12.4", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.5", + "generic-array", ] [[package]] @@ -192,16 +207,27 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" dependencies = [ - "generic-array 0.14.5", + "generic-array", ] [[package]] -name = "block-padding" -version = "0.1.5" +name = "bstr" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ - "byte-tools", + "lazy_static", + "memchr", + "regex-automata", +] + +[[package]] +name = "btoi" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97c0869a9faa81f8bbf8102371105d6d0a7b79167a04c340b04ab16892246a11" +dependencies = [ + "num-traits", ] [[package]] @@ -217,10 +243,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" [[package]] -name = "byte-tools" -version = "0.3.1" +name = "byte-unit" +version = "4.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +checksum = "95ebf10dda65f19ff0f42ea15572a359ed60d7fc74fdc984d90310937be0014b" +dependencies = [ + "utf8-width", +] [[package]] name = "byteorder" @@ -246,14 +275,20 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" +[[package]] +name = "castaway" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a17ed5635fc8536268e5d4de1e22e81ac34419e5f052d4d51f4e01dcc263fcc" +dependencies = [ + "rustversion", +] + [[package]] name = "cc" version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" -dependencies = [ - "jobserver", -] [[package]] name = "cfg-if" @@ -269,14 +304,15 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "6127248204b9aba09a362f6c930ef6a78f2c1b2215f8a7b398c06e1083f17af0" dependencies = [ - "libc", + "js-sys", "num-integer", "num-traits", "time 0.1.44", + "wasm-bindgen", "winapi", ] @@ -329,6 +365,21 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "clru" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "218d6bd3dde8e442a975fa1cd233c0e5fded7596bccfe39f58eca98d22421e0a" + +[[package]] +name = "cmake" +version = "0.1.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a" +dependencies = [ + "cc", +] + [[package]] name = "combine" version = "4.6.4" @@ -339,6 +390,17 @@ dependencies = [ "memchr", ] +[[package]] +name = "compact_str" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33b5c3ee2b4ffa00ac2b00d1645cd9229ade668139bccf95f15fadcf374127b" +dependencies = [ + "castaway", + "itoa", + "ryu", +] + [[package]] name = "concurrent-queue" version = "1.2.2" @@ -415,6 +477,29 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "crossbeam" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] + [[package]] name = "crossbeam-channel" version = "0.5.5" @@ -450,6 +535,16 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "crossbeam-queue" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd42583b04998a5363558e5f9291ee5a5ff6b49944332103f251e7479a82aa7" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.10" @@ -466,10 +561,22 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" dependencies = [ - "generic-array 0.14.5", + "generic-array", "typenum", ] +[[package]] +name = "dashmap" +version = "5.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3495912c9c1ccf2e18976439f4443f3fee0fd61f424ff99fde6a66b15ecb448f" +dependencies = [ + "cfg-if 1.0.0", + "hashbrown", + "lock_api", + "parking_lot_core 0.9.3", +] + [[package]] name = "deelevate" version = "0.2.0" @@ -501,22 +608,13 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.4", -] - [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.5", + "generic-array", ] [[package]] @@ -664,12 +762,6 @@ version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - [[package]] name = "fastrand" version = "1.7.0" @@ -690,6 +782,29 @@ dependencies = [ "winapi", ] +[[package]] +name = "filetime" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94a7bbaa59354bc20dd75b67f23e2797b4490e9d6928203fb105c79e448c86c" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "windows-sys", +] + +[[package]] +name = "flate2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +dependencies = [ + "crc32fast", + "libz-sys", + "miniz_oxide", +] + [[package]] name = "float-cmp" version = "0.9.0" @@ -774,15 +889,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - [[package]] name = "generic-array" version = "0.14.5" @@ -826,18 +932,414 @@ dependencies = [ ] [[package]] -name = "git2" -version = "0.14.4" +name = "git-actor" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0155506aab710a86160ddb504a480d2964d7ab5b9e62419be69e0032bc5931c" +checksum = "2a5d2a77331398a96dc6464f1602358f80831f8c1d482d9b36b8589b89727b46" +dependencies = [ + "bstr", + "btoi", + "git-date", + "itoa", + "nom 7.1.1", + "quick-error", +] + +[[package]] +name = "git-attributes" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d0551e2d2931a8af08fe587d1d109a621a521fb3f250bd8745653f70fda27f" +dependencies = [ + "bstr", + "compact_str", + "git-features", + "git-glob", + "git-path", + "git-quote", + "quick-error", + "unicode-bom", +] + +[[package]] +name = "git-bitmap" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7715cc94cd761fe92bb5626a332e4886292c7af88984abfdafad82dd56002475" +dependencies = [ + "quick-error", +] + +[[package]] +name = "git-chunk" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c915097c009d7870a27ee62dcadbf1410f07cdc6c510efcfb8c1011917bd4f22" +dependencies = [ + "quick-error", +] + +[[package]] +name = "git-config" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2517e4a1f8c82266debd70d43aac472ebc6cc403d4b4213e222d2c4d2c67aa97" dependencies = [ "bitflags", + "bstr", + "git-features", + "git-glob", + "git-path", + "git-ref", + "git-sec", "libc", - "libgit2-sys", + "memchr", + "nom 7.1.1", + "smallvec", + "thiserror", + "unicode-bom", +] + +[[package]] +name = "git-date" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de28bca8c01f1ed4e776bed75802c7f7e671da112496445dfcf885bc1a357250" +dependencies = [ + "bstr", + "itoa", + "time 0.3.11", +] + +[[package]] +name = "git-diff" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca9907f146e0ea61fabca745e45296a4da11cf4d6fd4d7aaa544ccc00f211419" +dependencies = [ + "git-hash", + "git-object", + "quick-error", +] + +[[package]] +name = "git-discover" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9db794b6e98c7fb9667c371d64a35534a4bfe088868a80efe4cfe38a71379bab" +dependencies = [ + "bstr", + "git-hash", + "git-path", + "git-ref", + "git-sec", + "thiserror", +] + +[[package]] +name = "git-features" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57bfebf2c0a0d28414aa7c3baa058d5c1c2969e553806904343a2c11483f425a" +dependencies = [ + "crc32fast", + "crossbeam-channel", + "crossbeam-utils", + "flate2", + "git-hash", + "jwalk", + "libc", + "num_cpus", + "once_cell", + "parking_lot 0.12.1", + "prodash", + "quick-error", + "sha1_smol", + "walkdir", +] + +[[package]] +name = "git-glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a226a7037e481a312ddba5cc55f6d7aa3eb5043d61e95c289af3632be942f0e" +dependencies = [ + "bitflags", + "bstr", +] + +[[package]] +name = "git-hash" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f82a0c09fdddeb738ed8338d214652c6d60ebf814a30d9ae1ecae7c91e0bbe81" +dependencies = [ + "hex", + "quick-error", +] + +[[package]] +name = "git-index" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b6795e3808f9ddc823c9864bec0ddb5c1e44479ac5aea0d6ff25ae0f0d657c1" +dependencies = [ + "atoi", + "bitflags", + "bstr", + "filetime", + "git-bitmap", + "git-features", + "git-hash", + "git-object", + "memmap2", + "quick-error", + "smallvec", +] + +[[package]] +name = "git-lock" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee44915b070cde930ecc0e251d53f40d2ad66354546edcfd04720b12e1936e91" +dependencies = [ + "fastrand", + "git-tempfile", + "quick-error", +] + +[[package]] +name = "git-object" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78bbda5da28d4bb564100373816dd21ba94709c39df12c114764967356430a8e" +dependencies = [ + "bstr", + "btoi", + "git-actor", + "git-features", + "git-hash", + "git-validate", + "hex", + "itoa", + "nom 7.1.1", + "quick-error", + "smallvec", +] + +[[package]] +name = "git-odb" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff0f045f8ef21a99fcd9ca540b5a3a7d9f50805316fc183da1e580978c9c561" +dependencies = [ + "arc-swap", + "git-features", + "git-hash", + "git-object", + "git-pack", + "git-path", + "git-quote", + "parking_lot 0.12.1", + "tempfile", + "thiserror", +] + +[[package]] +name = "git-pack" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02268bfe5fe46a6b8dfa5d14357cc1086eba134e254ca7703261ed00f142eb62" +dependencies = [ + "bytesize", + "clru", + "dashmap", + "git-chunk", + "git-diff", + "git-features", + "git-hash", + "git-object", + "git-path", + "git-tempfile", + "git-traverse", + "hash_hasher", + "memmap2", + "parking_lot 0.12.1", + "smallvec", + "thiserror", + "uluru", +] + +[[package]] +name = "git-path" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f054752f9f73d557f4ef0a4e48f2f7e01454abd7accdef9f85f0ef4fa2c6e8f" +dependencies = [ + "bstr", + "thiserror", +] + +[[package]] +name = "git-quote" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ec1960fa4f68a1637ce03d8c151ae2f8565d1de119a3eee8b5b9a364a08aacb" +dependencies = [ + "bstr", + "btoi", + "quick-error", +] + +[[package]] +name = "git-ref" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e365e9a3ee19ca10c9cd8f6f7ea4d464b6dfc73b5ef0f0cbc5747e29dfc14e93" +dependencies = [ + "git-actor", + "git-features", + "git-hash", + "git-lock", + "git-object", + "git-path", + "git-tempfile", + "git-validate", + "memmap2", + "nom 7.1.1", + "quick-error", +] + +[[package]] +name = "git-repository" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9636655207e546b2885248ead6252b54c319cca182914fd7a6cb1d499ab84dc3" +dependencies = [ + "byte-unit", + "clru", + "git-actor", + "git-config", + "git-date", + "git-diff", + "git-discover", + "git-features", + "git-hash", + "git-lock", + "git-object", + "git-odb", + "git-pack", + "git-path", + "git-ref", + "git-revision", + "git-sec", + "git-tempfile", + "git-traverse", + "git-url", + "git-validate", + "git-worktree", "log", + "signal-hook 0.3.14", + "thiserror", + "unicode-normalization", +] + +[[package]] +name = "git-revision" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "681181c8e87d96d6a47bafe1e4d8c9c7b0091c69573e69bd01422fc1a828f43d" +dependencies = [ + "bstr", + "git-date", + "git-hash", + "git-object", + "hash_hasher", + "thiserror", +] + +[[package]] +name = "git-sec" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffcecb38973b7c8fb3be5ae855a366a1e615fe1b7cf38d217f3e1adeb3608170" +dependencies = [ + "bitflags", + "dirs 4.0.0", + "git-path", + "libc", + "thiserror", + "windows 0.37.0", +] + +[[package]] +name = "git-tempfile" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c1d7753a96a332e404d6f985caa41bcbd6f08a8e40b4f452dd5e3985d4c4e8e" +dependencies = [ + "dashmap", + "libc", + "once_cell", + "signal-hook 0.3.14", + "signal-hook-registry", + "tempfile", +] + +[[package]] +name = "git-traverse" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fff51d777e90a9a46b6d556ff4715eace4a42d7fde546ef21a315a80d4121827" +dependencies = [ + "git-hash", + "git-object", + "hash_hasher", + "quick-error", +] + +[[package]] +name = "git-url" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650aa16382e135904f7303cd4156778df3979fc4f3589ea07d870444272486a3" +dependencies = [ + "bstr", + "git-features", + "git-path", + "home", + "quick-error", "url", ] +[[package]] +name = "git-validate" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c2c1eaaa942eb3c49ab20f27c0715e79e26e6b156a0f77d7ed7bbb26126a8fa" +dependencies = [ + "bstr", + "quick-error", +] + +[[package]] +name = "git-worktree" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a7e0c10fb0543096aa759e4f082866399e375ffb5e95a4f9e3dcdb3cd6ec488" +dependencies = [ + "bstr", + "git-attributes", + "git-features", + "git-glob", + "git-hash", + "git-index", + "git-object", + "git-path", + "io-close", + "thiserror", +] + [[package]] name = "guess_host_triple" version = "0.1.3" @@ -850,6 +1352,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "hash_hasher" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74721d007512d0cb3338cd20f0654ac913920061a4c4d0d8708edb3f2a698c0c" + [[package]] name = "hashbrown" version = "0.12.1" @@ -898,6 +1406,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "human_format" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86cce260d758a9aa3d7c4b99d55c815a540f8a37514ba6046ab6be402a157cb0" + [[package]] name = "iana-time-zone" version = "0.1.37" @@ -941,6 +1455,16 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "io-close" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cadcf447f06744f8ce713d2d6239bb5bde2c357a452397a9ed90c625da390bc" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "io-lifetimes" version = "0.7.2" @@ -968,15 +1492,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" -[[package]] -name = "jobserver" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" -dependencies = [ - "libc", -] - [[package]] name = "js-sys" version = "0.3.58" @@ -986,6 +1501,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jwalk" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "172752e853a067cbce46427de8470ddf308af7fd8ceaf9b682ef31a5021b6bb9" +dependencies = [ + "crossbeam", + "rayon", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -1004,18 +1529,6 @@ version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" -[[package]] -name = "libgit2-sys" -version = "0.13.4+1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0fa6563431ede25f5cc7f6d803c6afbc1c5d3ad3d4925d12c882bf2b526f5d1" -dependencies = [ - "cc", - "libc", - "libz-sys", - "pkg-config", -] - [[package]] name = "libz-sys" version = "1.1.8" @@ -1023,6 +1536,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" dependencies = [ "cc", + "cmake", "libc", "pkg-config", "vcpkg", @@ -1096,12 +1610,6 @@ dependencies = [ "libc", ] -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" - [[package]] name = "matches" version = "0.1.9" @@ -1114,6 +1622,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memmap2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a79b39c93a7a5a27eeaf9a23b5ff43f1b9e0ad6b1cdd441140ae53c35613fc7" +dependencies = [ + "libc", +] + [[package]] name = "memmem" version = "0.1.1" @@ -1135,6 +1652,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +[[package]] +name = "miniz_oxide" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" +dependencies = [ + "adler", +] + [[package]] name = "mockall" version = "0.11.2" @@ -1310,12 +1836,6 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -1363,9 +1883,9 @@ dependencies = [ [[package]] name = "os_info" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eca3ecae1481e12c3d9379ec541b238a16f0b75c9a409942daa8ec20dbfdb62" +checksum = "5209b2162b2c140df493a93689e04f8deab3a67634f5bc7a553c0a98e5b8d399" dependencies = [ "log", "serde", @@ -1392,7 +1912,17 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core", + "parking_lot_core 0.8.5", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.3", ] [[package]] @@ -1410,10 +1940,23 @@ dependencies = [ ] [[package]] -name = "path-slash" -version = "0.2.0" +name = "parking_lot_core" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54014ba3c1880122928735226f78b6f5bf5bd1fed15e41e92cf7aa20278ce28" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + +[[package]] +name = "path-slash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" [[package]] name = "pathdiff" @@ -1449,9 +1992,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.1.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" +checksum = "b13570633aff33c6d22ce47dd566b10a3b9122c2fe9d8e7501895905be532b91" dependencies = [ "pest", "pest_generator", @@ -1459,9 +2002,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.1.3" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" +checksum = "b3c567e5702efdc79fb18859ea74c3eb36e14c43da7b8c1f098a4ed6514ec7a0" dependencies = [ "pest", "pest_meta", @@ -1472,13 +2015,13 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.1.3" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" +checksum = "5eb32be5ee3bbdafa8c7a18b0a8a8d962b66cfa2ceee4037f49267a50ee821fe" dependencies = [ - "maplit", + "once_cell", "pest", - "sha-1 0.8.2", + "sha-1", ] [[package]] @@ -1659,6 +2202,22 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "prodash" +version = "19.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa75e7b3c1591d852ba49539ccac278cb2086e3f5cbbef0d9f5984b0fbcb4fcb" +dependencies = [ + "bytesize", + "human_format", +] + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + [[package]] name = "quick-xml" version = "0.23.0" @@ -1813,6 +2372,12 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + [[package]] name = "regex-syntax" version = "0.6.27" @@ -1852,12 +2417,27 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "rustversion" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24c8ad4f0c00e1eb5bc7614d236a7f1300e3dbd76b68cac8e06fb00b015ad8d8" + [[package]] name = "ryu" version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schemars" version = "0.8.10" @@ -1900,9 +2480,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1" +checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711" [[package]] name = "semver-parser" @@ -1915,18 +2495,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.140" +version = "1.0.143" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03" +checksum = "53e8e5d5b70924f74ff5c6d64d9a5acd91422117c60f48c4e07855238a254553" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.140" +version = "1.0.143" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f2122636b9fe3b81f1cb25099fcf2d3f542cdb1d45940d56c713158884a05da" +checksum = "d3d8e8de557aee63c26b85b947f5e59b690d0454c753f3adeb5cd7835ab88391" dependencies = [ "proc-macro2", "quote", @@ -1946,9 +2526,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" +checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7" dependencies = [ "itoa", "ryu", @@ -1966,18 +2546,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sha-1" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - [[package]] name = "sha-1" version = "0.10.0" @@ -2014,7 +2582,7 @@ dependencies = [ "cfg-if 1.0.0", "cpufeatures", "digest 0.9.0", - "opaque-debug 0.3.0", + "opaque-debug", ] [[package]] @@ -2024,7 +2592,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2d399ad15b5c90d8e6461da75c751c77501598dd915d81a108401b252aaa99f" dependencies = [ "const_format", - "git2", "is_debug", "time 0.3.11", "tzdb", @@ -2089,9 +2656,9 @@ checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" [[package]] name = "smallvec" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc88c725d61fc6c3132893370cac4a0200e3fedf5da8331c570664b1987f5ca2" +checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" [[package]] name = "socket2" @@ -2115,7 +2682,7 @@ dependencies = [ "dirs-next", "dunce", "gethostname", - "git2", + "git-repository", "guess_host_triple", "home", "indexmap", @@ -2137,10 +2704,10 @@ dependencies = [ "regex", "rust-ini", "schemars", - "semver 1.0.12", + "semver 1.0.13", "serde", "serde_json", - "sha-1 0.10.0", + "sha-1", "shadow-rs", "shell-words", "starship-battery", @@ -2491,6 +3058,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "uluru" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "794a32261a1f5eb6a4462c81b59cec87b5c27d5deea7dd1ac8fc781c41d226db" +dependencies = [ + "arrayvec", +] + [[package]] name = "unicase" version = "2.6.0" @@ -2506,6 +3082,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +[[package]] +name = "unicode-bom" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63ec69f541d875b783ca40184d655f2927c95f0bffd486faa83cd3ac3529ec32" + [[package]] name = "unicode-ident" version = "1.0.1" @@ -2567,6 +3149,12 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68b90931029ab9b034b300b797048cf23723400aa757e8a2bfb9d748102f9821" +[[package]] +name = "utf8-width" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1" + [[package]] name = "utf8parse" version = "0.2.0" @@ -2610,6 +3198,17 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -2745,6 +3344,19 @@ dependencies = [ "windows_x86_64_msvc 0.24.0", ] +[[package]] +name = "windows" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57b543186b344cc61c85b5aab0d2e3adf4e0f99bc076eff9aa5927bcc0b8a647" +dependencies = [ + "windows_aarch64_msvc 0.37.0", + "windows_i686_gnu 0.37.0", + "windows_i686_msvc 0.37.0", + "windows_x86_64_gnu 0.37.0", + "windows_x86_64_msvc 0.37.0", +] + [[package]] name = "windows" version = "0.39.0" @@ -2777,6 +3389,12 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +[[package]] +name = "windows_aarch64_msvc" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a" + [[package]] name = "windows_aarch64_msvc" version = "0.39.0" @@ -2795,6 +3413,12 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +[[package]] +name = "windows_i686_gnu" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1" + [[package]] name = "windows_i686_gnu" version = "0.39.0" @@ -2813,6 +3437,12 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +[[package]] +name = "windows_i686_msvc" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c" + [[package]] name = "windows_i686_msvc" version = "0.39.0" @@ -2831,6 +3461,12 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d" + [[package]] name = "windows_x86_64_gnu" version = "0.39.0" @@ -2849,6 +3485,12 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +[[package]] +name = "windows_x86_64_msvc" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d" + [[package]] name = "windows_x86_64_msvc" version = "0.39.0" diff --git a/Cargo.toml b/Cargo.toml index 7eb9e2a20..054568775 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,9 +22,8 @@ keywords = ["prompt", "shell", "bash", "fish", "zsh"] license = "ISC" readme = "README.md" repository = "https://github.com/starship/starship" -# MSRV is specified due to our dependency in git2 # Note: MSRV is only intended as a hint, and only the latest version is officially supported in starship. -rust-version = "1.60" +rust-version = "1.59" description = """ The minimal, blazing-fast, and infinitely customizable prompt for any shell! ☄🌌️ """ @@ -37,13 +36,13 @@ notify = ["notify-rust"] [dependencies] ansi_term = "0.12.1" -chrono = "0.4.19" +chrono = { version = "0.4.20", features = ["clock", "std"] } clap = { version = "=3.2.16", features = ["derive", "cargo", "unicode", "unstable-v4"] } clap_complete = "3.2.3" dirs-next = "2.0.0" dunce = "1.0.2" gethostname = "0.2.3" -git2 = { version = "0.14.4", default-features = false } +git-repository = "0.20.0" indexmap = { version = "1.9.1", features = ["serde"] } local_ipaddress = "0.1.3" log = { version = "0.4.16", features = ["std"] } @@ -52,20 +51,20 @@ log = { version = "0.4.16", features = ["std"] } notify-rust = { version = "4.5.8", optional = true } once_cell = "1.13.0" open = "3.0.2" -os_info = "3.4.0" -path-slash = "0.2.0" +os_info = "3.5.0" +path-slash = "0.2.1" pest = "2.2.1" -pest_derive = "2.1.0" +pest_derive = "2.2.1" quick-xml = "0.23.0" rand = "0.8.5" rayon = "1.5.3" regex = "1.6.0" rust-ini = "0.18.0" -semver = "1.0.12" -serde = { version = "1.0.140", features = ["derive"] } -serde_json = "1.0.82" +semver = "1.0.13" +serde = { version = "1.0.143", features = ["derive"] } +serde_json = "1.0.83" sha-1 = "0.10.0" -shadow-rs = "0.16.1" +shadow-rs = { version = "0.16.1", default-features = false } # battery is optional (on by default) because the crate doesn't currently build for Termux # see: https://github.com/svartalf/rust-battery/issues/33 starship-battery = { version = "0.7.9", optional = true } @@ -109,7 +108,8 @@ features = [ nix = { version = "0.24.2", default-features = false, features = ["feature", "fs", "user"] } [build-dependencies] -shadow-rs = "0.16.1" +shadow-rs = { version = "0.16.1", default-features = false } +dunce = "1.0.2" [target.'cfg(windows)'.build-dependencies] winres = "0.1.12" diff --git a/build.rs b/build.rs index 38b4e1ac5..7a6753419 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,11 @@ -use std::error::Error; +use std::fs::{self, File}; +use std::io::Write; -fn main() -> Result<(), Box> { +use shadow_rs::SdResult; + +fn main() -> SdResult<()> { shadow_rs::new().map_err(|err| err.to_string())?; + shadow_rs::new_hook(gen_presets_hook)?; #[cfg(windows)] { @@ -13,3 +17,55 @@ fn main() -> Result<(), Box> { Ok(()) } + +fn gen_presets_hook(mut file: &File) -> SdResult<()> { + println!("cargo:rerun-if-changed=docs/.vuepress/public/presets/toml"); + let paths = fs::read_dir("docs/.vuepress/public/presets/toml")?; + + let mut presets = String::new(); + let mut match_arms = String::new(); + for path in paths { + let unwrapped = path?; + let file_name = unwrapped.file_name(); + let full_path = dunce::canonicalize(unwrapped.path())?; + let full_path = full_path.to_str().expect("failed to convert to string"); + let name = file_name + .to_str() + .and_then(|v| v.strip_suffix(".toml")) + .expect("Failed to process filename"); + presets.push_str(format!("print::Preset(\"{}\"),\n", name).as_str()); + match_arms.push_str( + format!( + r#" +"{name}" => {{ + let mut stdout = io::stdout().lock(); + let _ = stdout.write_all(include_bytes!(r"{full_path}")); +}} +"# + ) + .as_str(), + ); + } + + writeln!( + file, + r#" +use std::io::{{self, Write}}; +use crate::print; + +pub fn get_preset_list<'a>() -> &'a [print::Preset] {{ + &[ + {presets} + ] +}} + +pub fn print_preset_content(name: &str) {{ + match name {{ + {match_arms} + _ => {{}} + }} +}} +"# + )?; + Ok(()) +} diff --git a/docs/presets/bracketed-segments.md b/docs/presets/bracketed-segments.md index f595e7778..921f58bdb 100644 --- a/docs/presets/bracketed-segments.md +++ b/docs/presets/bracketed-segments.md @@ -9,6 +9,10 @@ in brackets instead of using the default Starship wording ("via", "on", etc.). ### Configuration +```sh +starship preset bracketed-segments > ~/.config/starship.toml +``` + [Click to download TOML](/presets/toml/bracketed-segments.toml) <<< @/.vuepress/public/presets/toml/bracketed-segments.toml diff --git a/docs/presets/nerd-font.md b/docs/presets/nerd-font.md index c5810efff..f523d01c6 100644 --- a/docs/presets/nerd-font.md +++ b/docs/presets/nerd-font.md @@ -12,6 +12,10 @@ This preset changes the symbols for each module to use Nerd Font symbols. ### Configuration +```sh +starship preset nerd-font-symbols > ~/.config/starship.toml +``` + [Click to download TOML](/presets/toml/nerd-font-symbols.toml) <<< @/.vuepress/public/presets/toml/nerd-font-symbols.toml diff --git a/docs/presets/no-runtimes.md b/docs/presets/no-runtimes.md index fd3050513..a8b326cc6 100644 --- a/docs/presets/no-runtimes.md +++ b/docs/presets/no-runtimes.md @@ -8,6 +8,10 @@ This preset hides the version of language runtimes. If you work in containers or ### Configuration +```sh +starship preset no-runtime-versions > ~/.config/starship.toml +``` + [Click to download TOML](/presets/toml/no-runtime-versions.toml) <<< @/.vuepress/public/presets/toml/no-runtime-versions.toml diff --git a/docs/presets/pastel-powerline.md b/docs/presets/pastel-powerline.md index 5488b00a2..72c8d0009 100644 --- a/docs/presets/pastel-powerline.md +++ b/docs/presets/pastel-powerline.md @@ -13,6 +13,10 @@ It also shows how path substitution works in starship. ### Configuration +```sh +starship preset pastel-powerline > ~/.config/starship.toml +``` + [Click to download TOML](/presets/toml/pastel-powerline.toml) <<< @/.vuepress/public/presets/toml/pastel-powerline.toml diff --git a/docs/presets/plain-text.md b/docs/presets/plain-text.md index 6c38c49a7..9f9e45924 100644 --- a/docs/presets/plain-text.md +++ b/docs/presets/plain-text.md @@ -9,6 +9,10 @@ don't have access to Unicode. ### Configuration +```sh +starship preset plain-text-symbols > ~/.config/starship.toml +``` + [Click to download TOML](/presets/toml/plain-text-symbols.toml) <<< @/.vuepress/public/presets/toml/plain-text-symbols.toml diff --git a/docs/presets/pure-preset.md b/docs/presets/pure-preset.md index ad61b4995..ae1e85fc4 100644 --- a/docs/presets/pure-preset.md +++ b/docs/presets/pure-preset.md @@ -8,6 +8,10 @@ This preset emulates the look and behavior of [Pure](https://github.com/sindreso ### Configuration +```sh +starship preset pure-preset > ~/.config/starship.toml +``` + [Click to download TOML](/presets/toml/pure-preset.toml) <<< @/.vuepress/public/presets/toml/pure-preset.toml diff --git a/src/context.rs b/src/context.rs index 404cf5aaf..bd00ce388 100644 --- a/src/context.rs +++ b/src/context.rs @@ -6,7 +6,11 @@ use crate::utils::{create_command, exec_timeout, read_file, CommandOutput}; use crate::modules; use crate::utils::{self, home_dir}; use clap::Parser; -use git2::{ErrorCode::UnbornBranch, Repository, RepositoryState}; +use git_repository::{ + self as git, + sec::{self as git_sec, trust::DefaultForLevel}, + state as git_state, Repository, ThreadSafeRepository, +}; use once_cell::sync::OnceCell; #[cfg(test)] use std::collections::HashMap; @@ -255,22 +259,51 @@ impl<'a> Context<'a> { } /// Will lazily get repo root and branch when a module requests it. - pub fn get_repo(&self) -> Result<&Repo, git2::Error> { - self.repo.get_or_try_init(|| -> Result { - let repository = if env::var("GIT_DIR").is_ok() { - Repository::open_from_env() - } else { - let dirs: [PathBuf; 0] = []; - Repository::open_ext(&self.current_dir, git2::RepositoryOpenFlags::FROM_ENV, dirs) - }?; - Ok(Repo { - branch: get_current_branch(&repository), - workdir: repository.workdir().map(Path::to_path_buf), - path: Path::to_path_buf(repository.path()), - state: repository.state(), - remote: get_remote_repository_info(&repository), + pub fn get_repo(&self) -> Result<&Repo, git::discover::Error> { + self.repo + .get_or_try_init(|| -> Result { + // custom open options + let mut git_open_opts_map = + git_sec::trust::Mapping::::default(); + + // don't use the global git configs + let config = git::permissions::Config { + system: false, + git: false, + user: false, + env: true, + includes: true, + }; + // change options for config permissions without touching anything else + git_open_opts_map.reduced = + git_open_opts_map.reduced.permissions(git::Permissions { + config, + ..git::Permissions::default_for_level(git_sec::Trust::Reduced) + }); + git_open_opts_map.full = git_open_opts_map.full.permissions(git::Permissions { + config, + ..git::Permissions::default_for_level(git_sec::Trust::Full) + }); + + let shared_repo = ThreadSafeRepository::discover_with_environment_overrides_opts( + &self.current_dir, + Default::default(), + git_open_opts_map, + )?; + + let repository = shared_repo.to_thread_local(); + let branch = get_current_branch(&repository); + let remote = get_remote_repository_info(&repository, branch.as_deref()); + let path = repository.path().to_path_buf(); + Ok(Repo { + repo: shared_repo, + branch, + workdir: repository.work_dir().map(PathBuf::from), + path, + state: repository.state(), + remote, + }) }) - }) } pub fn dir_contents(&self) -> Result<&DirContents, std::io::Error> { @@ -494,6 +527,8 @@ impl DirContents { } pub struct Repo { + pub repo: ThreadSafeRepository, + /// If `current_dir` is a git repository or is contained within one, /// this is the current branch name of that repo. pub branch: Option, @@ -506,7 +541,7 @@ pub struct Repo { pub path: PathBuf, /// State - pub state: RepositoryState, + pub state: Option, /// Remote repository pub remote: Option, @@ -514,8 +549,8 @@ pub struct Repo { impl Repo { /// Opens the associated git repository. - pub fn open(&self) -> Result { - Repository::open(&self.path) + pub fn open(&self) -> Repository { + self.repo.to_thread_local() } } @@ -570,54 +605,26 @@ impl<'a> ScanDir<'a> { } fn get_current_branch(repository: &Repository) -> Option { - let head = match repository.head() { - Ok(reference) => reference, - Err(e) => { - return if e.code() == UnbornBranch { - // HEAD should only be an unborn branch if the repository is fresh, - // in that case read directly from `.git/HEAD` - let mut head_path = repository.path().to_path_buf(); - head_path.push("HEAD"); + let name = repository.head_name().ok()??; + let shorthand = name.shorten(); - // get first line, then last path segment - fs::read_to_string(&head_path) - .ok()? - .lines() - .next()? - .trim() - .split('/') - .last() - .map(std::borrow::ToOwned::to_owned) - } else { - None - }; - } - }; - - let shorthand = head.shorthand(); - - shorthand.map(std::string::ToString::to_string) + Some(shorthand.to_string()) } -fn get_remote_repository_info(repository: &Repository) -> Option { - if let Ok(head) = repository.head() { - if let Some(local_branch_ref) = head.name() { - let remote_ref = match repository.branch_upstream_name(local_branch_ref) { - Ok(remote_ref) => remote_ref.as_str()?.to_owned(), - Err(_) => return None, - }; +fn get_remote_repository_info( + repository: &Repository, + branch_name: Option<&str>, +) -> Option { + let branch_name = branch_name?; + let branch = repository + .remote_ref(branch_name) + .and_then(|r| r.ok()) + .map(|r| r.shorten().to_string()); + let name = repository + .branch_remote_name(branch_name) + .map(|n| n.to_string()); - let mut v = remote_ref.splitn(4, '/'); - let remote_name = v.nth(2)?.to_owned(); - let remote_branch = v.last()?.to_owned(); - - return Some(Remote { - branch: Some(remote_branch), - name: Some(remote_name), - }); - } - } - None + Some(Remote { branch, name }) } #[derive(Debug, Clone, Copy, PartialEq, Eq)] diff --git a/src/main.rs b/src/main.rs index fba5a094f..0e4ba6538 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,6 +63,15 @@ enum Commands { #[clap(flatten)] properties: Properties, }, + /// Prints a preset config + Preset { + /// The name of preset to be printed + #[clap(required_unless_present("list"), value_enum)] + name: Option, + /// List out all preset names + #[clap(short, long)] + list: bool, + }, /// Prints the computed starship configuration PrintConfig { /// Print the default instead of the computed config @@ -182,6 +191,7 @@ fn main() { print::module(&module_name, properties); } } + Commands::Preset { name, list } => print::preset_command(name, list), Commands::Config { name, value } => { if let Some(name) = name { if let Some(value) = value { diff --git a/src/modules/directory.rs b/src/modules/directory.rs index 4da1250c2..87c702bdd 100644 --- a/src/modules/directory.rs +++ b/src/modules/directory.rs @@ -113,12 +113,12 @@ pub fn module<'a>(context: &'a Context) -> Option> { { let root = repo_path_vec[0]; let before = dir_string.replace(&contracted_path, ""); - [prefix + &before, root.to_string(), after_repo_root] + [prefix + before.as_str(), root.to_string(), after_repo_root] } else { - ["".to_string(), "".to_string(), prefix + &dir_string] + ["".to_string(), "".to_string(), prefix + dir_string.as_str()] } } - _ => ["".to_string(), "".to_string(), prefix + &dir_string], + _ => ["".to_string(), "".to_string(), prefix + dir_string.as_str()], }; let path_vec = if config.use_os_path_sep { diff --git a/src/modules/git_branch.rs b/src/modules/git_branch.rs index 8d96a8bb4..46591d625 100644 --- a/src/modules/git_branch.rs +++ b/src/modules/git_branch.rs @@ -26,12 +26,8 @@ pub fn module<'a>(context: &'a Context) -> Option> { let repo = context.get_repo().ok()?; - if config.only_attached { - if let Ok(git_repo) = repo.open() { - if git_repo.head_detached().ok()? { - return None; - } - } + if config.only_attached && repo.open().head().ok()?.is_detached() { + return None; } let branch_name = repo.branch.as_ref()?; diff --git a/src/modules/git_commit.rs b/src/modules/git_commit.rs index e536ff3f8..bc2fba510 100644 --- a/src/modules/git_commit.rs +++ b/src/modules/git_commit.rs @@ -1,8 +1,8 @@ use super::{Context, Module, ModuleConfig}; -use crate::formatter::string_formatter::StringFormatterError; -use git2::Time; +use git_repository::commit::describe::SelectRef::AnnotatedTags; use crate::configs::git_commit::GitCommitConfig; +use crate::context::Repo; use crate::formatter::StringFormatter; /// Creates a module with the Git commit in the current directory @@ -13,45 +13,14 @@ pub fn module<'a>(context: &'a Context) -> Option> { let config: GitCommitConfig = GitCommitConfig::try_load(module.config); let repo = context.get_repo().ok()?; - let git_repo = repo.open().ok()?; + let git_repo = repo.open(); + let git_head = git_repo.head().ok()?; - let is_detached = git_repo.head_detached().ok()?; + let is_detached = git_head.is_detached(); if config.only_detached && !is_detached { return None; }; - let git_head = git_repo.head().ok()?; - let head_commit = git_head.peel_to_commit().ok()?; - let commit_oid = head_commit.id(); - - let mut tag_name = String::new(); - if !config.tag_disabled { - // Let's get repo tags names - let tag_names = git_repo.tag_names(None).ok()?; - let tag_and_refs = tag_names.iter().flatten().flat_map(|name| { - let full_tag = format!("refs/tags/{}", name); - let tag_obj = git_repo.find_reference(&full_tag)?.peel_to_tag()?; - let sig_obj = tag_obj.tagger(); - git_repo.find_reference(&full_tag).map(|reference| { - ( - String::from(name), - // fall back to oldest + 1s time if sig_obj is unavailable - sig_obj.map_or(git2::Time::new(1, 0), |s| s.when()), - reference, - ) - }) - }); - - let mut oldest = Time::new(0, 0); - // Let's check if HEAD has some tag. If several, gets last created one... - for (name, timestamp, reference) in tag_and_refs.rev() { - if commit_oid == reference.peel_to_commit().ok()?.id() && timestamp > oldest { - tag_name = name; - oldest = timestamp; - } - } - }; - let parsed = StringFormatter::new(config.format).and_then(|formatter| { formatter .map_style(|variable| match variable { @@ -59,11 +28,12 @@ pub fn module<'a>(context: &'a Context) -> Option> { _ => None, }) .map(|variable| match variable { - "hash" => Some(Ok(id_to_hex_abbrev( - commit_oid.as_bytes(), - config.commit_hash_length, + "hash" => Some(Ok(git_hash(context.get_repo().ok()?, &config)?)), + "tag" => Some(Ok(format!( + "{}{}", + config.tag_symbol, + git_tag(context.get_repo().ok()?)? ))), - "tag" => format_tag(config.tag_symbol, &tag_name), _ => None, }) .parse(None, Some(context)) @@ -80,23 +50,24 @@ pub fn module<'a>(context: &'a Context) -> Option> { Some(module) } -fn format_tag(symbol: &str, tag_name: &str) -> Option> { - if tag_name.is_empty() { - None - } else { - Some(Ok(format!("{}{}", &symbol, &tag_name))) - } +fn git_tag(repo: &Repo) -> Option { + let git_repo = repo.open(); + let head_commit = git_repo.head_commit().ok()?; + + let describe_platform = head_commit.describe().names(AnnotatedTags); + let formatter = describe_platform.try_format().ok()??; + + Some(formatter.name?.to_string()) } -/// len specifies length of hex encoded string -fn id_to_hex_abbrev(bytes: &[u8], len: usize) -> String { - bytes - .iter() - .map(|b| format!("{:02x}", b)) - .collect::() - .chars() - .take(len) - .collect() +fn git_hash(repo: &Repo, config: &GitCommitConfig) -> Option { + let git_repo = repo.open(); + let head_id = git_repo.head_id().ok()?; + + Some(format!( + "{}", + head_id.to_hex_with_len(config.commit_hash_length) + )) } #[cfg(test)] diff --git a/src/modules/git_state.rs b/src/modules/git_state.rs index 526e8069d..92727933f 100644 --- a/src/modules/git_state.rs +++ b/src/modules/git_state.rs @@ -1,4 +1,4 @@ -use git2::RepositoryState; +use git_repository::state::InProgress; use std::path::PathBuf; use super::{Context, Module, ModuleConfig}; @@ -54,54 +54,53 @@ fn get_state_description<'a>( repo: &'a Repo, config: &GitStateConfig<'a>, ) -> Option> { - match repo.state { - RepositoryState::Clean => None, - RepositoryState::Merge => Some(StateDescription { + match repo.state.as_ref()? { + InProgress::Merge => Some(StateDescription { label: config.merge, current: None, total: None, }), - RepositoryState::Revert => Some(StateDescription { + InProgress::Revert => Some(StateDescription { label: config.revert, current: None, total: None, }), - RepositoryState::RevertSequence => Some(StateDescription { + InProgress::RevertSequence => Some(StateDescription { label: config.revert, current: None, total: None, }), - RepositoryState::CherryPick => Some(StateDescription { + InProgress::CherryPick => Some(StateDescription { label: config.cherry_pick, current: None, total: None, }), - RepositoryState::CherryPickSequence => Some(StateDescription { + InProgress::CherryPickSequence => Some(StateDescription { label: config.cherry_pick, current: None, total: None, }), - RepositoryState::Bisect => Some(StateDescription { + InProgress::Bisect => Some(StateDescription { label: config.bisect, current: None, total: None, }), - RepositoryState::ApplyMailbox => Some(StateDescription { + InProgress::ApplyMailbox => Some(StateDescription { label: config.am, current: None, total: None, }), - RepositoryState::ApplyMailboxOrRebase => Some(StateDescription { + InProgress::ApplyMailboxRebase => Some(StateDescription { label: config.am_or_rebase, current: None, total: None, }), - RepositoryState::Rebase => Some(describe_rebase(repo, config.rebase)), - RepositoryState::RebaseInteractive => Some(describe_rebase(repo, config.rebase)), - RepositoryState::RebaseMerge => Some(describe_rebase(repo, config.rebase)), + InProgress::Rebase => Some(describe_rebase(repo, config.rebase)), + InProgress::RebaseInteractive => Some(describe_rebase(repo, config.rebase)), } } +// TODO: Use future gitoxide API to get the state of the rebase fn describe_rebase<'a>(repo: &'a Repo, rebase_config: &'a str) -> StateDescription<'a> { /* * Sadly, libgit2 seems to have some issues with reading the state of diff --git a/src/modules/git_status.rs b/src/modules/git_status.rs index d90f8e8f7..aa3f03878 100644 --- a/src/modules/git_status.rs +++ b/src/modules/git_status.rs @@ -34,6 +34,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { //Return None if not in git repository context.get_repo().ok()?; + if let Some(git_status) = git_status_wsl(context, &config) { if git_status.is_empty() { return None; diff --git a/src/modules/hg_branch.rs b/src/modules/hg_branch.rs index ae1ac7377..aa048a579 100644 --- a/src/modules/hg_branch.rs +++ b/src/modules/hg_branch.rs @@ -41,7 +41,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { // The truncation symbol should only be added if we truncated let truncated_and_symbol = if len < graphemes_len(&branch_name) { let truncation_symbol = get_graphemes(config.truncation_symbol, 1); - truncated_graphemes + &truncation_symbol + truncated_graphemes + truncation_symbol.as_str() } else { truncated_graphemes }; diff --git a/src/modules/hostname.rs b/src/modules/hostname.rs index 3621dc320..fdb991941 100644 --- a/src/modules/hostname.rs +++ b/src/modules/hostname.rs @@ -150,7 +150,7 @@ mod tests { .collect(); let expected = Some(format!( "{} in ", - style().paint("🌐 ".to_owned() + &hostname) + style().paint("🌐 ".to_owned() + hostname.as_str()) )); assert_eq!(expected, actual); diff --git a/src/print.rs b/src/print.rs index 4c3a3c2f7..67572cd3c 100644 --- a/src/print.rs +++ b/src/print.rs @@ -1,4 +1,5 @@ use ansi_term::ANSIStrings; +use clap::{PossibleValue, ValueEnum}; use rayon::prelude::*; use std::collections::BTreeSet; use std::fmt::{self, Debug, Write as FmtWrite}; @@ -15,6 +16,7 @@ use crate::module::Module; use crate::module::ALL_MODULES; use crate::modules; use crate::segment::Segment; +use crate::shadow; pub struct Grapheme<'a>(pub &'a str); @@ -450,6 +452,35 @@ pub fn print_schema() { println!("{}", serde_json::to_string_pretty(&schema).unwrap()); } +#[derive(Clone, Debug)] +pub struct Preset(pub &'static str); + +impl ValueEnum for Preset { + fn value_variants<'a>() -> &'a [Self] { + shadow::get_preset_list() + } + + fn to_possible_value<'a>(&self) -> Option> { + Some(PossibleValue::new(self.0)) + } +} + +pub fn preset_command(name: Option, list: bool) { + if list { + println!("{}", preset_list()); + return; + } + let variant = name.expect("name argument must be specified"); + shadow::print_preset_content(variant.0); +} + +fn preset_list() -> String { + Preset::value_variants() + .iter() + .map(|v| format!("{}\n", v.0)) + .collect() +} + #[cfg(test)] mod test { use super::*; @@ -490,6 +521,19 @@ mod test { assert_eq!(expected, actual); } + #[test] + fn preset_list_returns_one_or_more_items() { + assert!(preset_list().trim().split('\n').count() > 0); + } + + #[test] + fn preset_command_does_not_panic_on_correct_inputs() { + preset_command(None, true); + Preset::value_variants() + .iter() + .for_each(|v| preset_command(Some(v.clone()), false)); + } + #[test] #[cfg(feature = "config-schema")] fn print_schema_does_not_panic() {