From ac55a01d0ffe907ef7af48c9597c0bca4dbd8c69 Mon Sep 17 00:00:00 2001 From: David Knaack Date: Tue, 9 Aug 2022 04:33:00 +0200 Subject: [PATCH] feat(git): replace `git2` with `git-repository` (#3883) --- Cargo.lock | 784 ++++++++++++++++++++++++++++++++++++-- Cargo.toml | 9 +- src/context.rs | 133 ++++--- src/modules/directory.rs | 6 +- src/modules/git_branch.rs | 8 +- src/modules/git_commit.rs | 81 ++-- src/modules/git_state.rs | 27 +- src/modules/git_status.rs | 1 + src/modules/hg_branch.rs | 2 +- src/modules/hostname.rs | 2 +- 10 files changed, 871 insertions(+), 182 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ff99b72f..8738f85bf 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" @@ -183,6 +210,26 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "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]] name = "bumpalo" version = "3.10.0" @@ -195,6 +242,15 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" +[[package]] +name = "byte-unit" +version = "4.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ebf10dda65f19ff0f42ea15572a359ed60d7fc74fdc984d90310937be0014b" +dependencies = [ + "utf8-width", +] + [[package]] name = "byteorder" version = "1.4.3" @@ -219,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" @@ -303,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" @@ -313,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" @@ -389,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" @@ -424,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" @@ -444,6 +565,18 @@ dependencies = [ "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" @@ -649,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" @@ -776,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" @@ -800,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" @@ -848,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" @@ -891,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" @@ -918,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" @@ -936,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" @@ -954,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" @@ -973,6 +1536,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" dependencies = [ "cc", + "cmake", "libc", "pkg-config", "vcpkg", @@ -1058,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" @@ -1079,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" @@ -1330,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]] @@ -1347,6 +1939,19 @@ dependencies = [ "winapi", ] +[[package]] +name = "parking_lot_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + [[package]] name = "path-slash" version = "0.2.1" @@ -1597,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" @@ -1751,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" @@ -1790,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" @@ -1950,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", @@ -2015,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" @@ -2041,7 +2682,7 @@ dependencies = [ "dirs-next", "dunce", "gethostname", - "git2", + "git-repository", "guess_host_triple", "home", "indexmap", @@ -2417,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" @@ -2432,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" @@ -2493,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" @@ -2536,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" @@ -2671,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" @@ -2703,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" @@ -2721,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" @@ -2739,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" @@ -2757,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" @@ -2775,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 24f87b70e..bbd88beca 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! ☄🌌️ """ @@ -43,7 +42,7 @@ 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"] } @@ -65,7 +64,7 @@ semver = "1.0.13" serde = { version = "1.0.142", 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,7 @@ 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] 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/modules/directory.rs b/src/modules/directory.rs index 29dc94bd1..99c9b8ad7 100644 --- a/src/modules/directory.rs +++ b/src/modules/directory.rs @@ -112,12 +112,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);