diff --git a/.github/workflows/msrv.yml b/.github/workflows/msrv.yml index f16da43f3a8..726539e173b 100644 --- a/.github/workflows/msrv.yml +++ b/.github/workflows/msrv.yml @@ -20,7 +20,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@1.60.0 # dictated by `windows` crates effectively, IMPORTANT: adjust etc/msrv-badge.svg as well + - uses: dtolnay/rust-toolchain@1.64.0 # dictated by `windows` crates effectively, IMPORTANT: adjust etc/msrv-badge.svg as well - run: make check-msrv-on-ci continue-on-error: true # TODO: turn this off once the toolchain gets updated. There is a strange error preventing cargo to select the correct libgit2 version # like it doesn't exist. diff --git a/Cargo.lock b/Cargo.lock index cda99e2082b..94a80dd1655 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -129,7 +129,7 @@ dependencies = [ "slab", "socket2", "waker-fn", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -189,9 +189,9 @@ checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" [[package]] name = "async-trait" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d1d8ab452a3936018a687b20e6f7cf5363d713b732b8884001317b0e48aa3" +checksum = "705339e0e4a9690e2908d2b3d049d85682cf19fbd5782494498fbf7003a6a282" dependencies = [ "proc-macro2", "quote", @@ -236,6 +236,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + [[package]] name = "bitflags" version = "1.3.2" @@ -315,9 +321,9 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad0e1e3e88dd237a156ab9f571021b8a158caa0ae44b1968a241efb5144c1e" +checksum = "c77df041dc383319cc661b428b6961a005db4d6808d5e12536931b1ca9556055" dependencies = [ "serde", ] @@ -341,7 +347,7 @@ dependencies = [ "cargo_toml", "clap", "crates-index", - "env_logger 0.9.3", + "env_logger", "git-conventional", "git-repository", "git-testtools", @@ -371,12 +377,11 @@ dependencies = [ [[package]] name = "cargo_toml" -version = "0.11.8" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e72c3ff59e3b7d24630206bb63a73af65da4ed5df1f76ee84dfafb9fee2ba60e" +checksum = "0f1204fe51a1e56042b8ec31d6407547ecd18f596b66f470dadb9abd9be9c843" dependencies = [ "serde", - "serde_derive", "toml", ] @@ -497,16 +502,6 @@ dependencies = [ "cc", ] -[[package]] -name = "combine" -version = "4.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" -dependencies = [ - "bytes", - "memchr", -] - [[package]] name = "compact_str" version = "0.6.1" @@ -539,14 +534,14 @@ dependencies = [ [[package]] name = "console" -version = "0.15.3" +version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5556015fe3aad8b968e5d4124980fbe2f6aaee7aeec6b749de1faaa2ca5d0a4c" +checksum = "c9b6515d269224923b26b5febea2ed42b2d5f2ce37284a4dd670fedd6cb8347a" dependencies = [ "encode_unicode", "lazy_static", "libc", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -923,18 +918,6 @@ dependencies = [ "syn", ] -[[package]] -name = "env_logger" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" -dependencies = [ - "atty", - "humantime", - "log", - "termcolor", -] - [[package]] name = "env_logger" version = "0.10.0" @@ -976,12 +959,12 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "expectrl" -version = "0.5.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2795e11f4ee3124984d454f25ac899515a5fa6d956562ef2b147fef6050b02f8" +checksum = "1ae3a1de9c4a0cfc3badf6f98bf0736fe3f05e3b6da5b8f5288a4726fcc6f746" dependencies = [ "conpty", - "nix 0.23.2", + "nix 0.25.1", "ptyprocess", "regex", ] @@ -1004,7 +987,7 @@ dependencies = [ "cfg-if", "libc", "redox_syscall", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -1767,7 +1750,7 @@ dependencies = [ "libc", "serde", "tempfile", - "windows 0.40.0", + "windows 0.43.0", ] [[package]] @@ -1823,7 +1806,7 @@ version = "0.25.2" dependencies = [ "async-std", "async-trait", - "base64", + "base64 0.21.0", "blocking", "bstr", "curl", @@ -1930,7 +1913,7 @@ dependencies = [ "clap", "crosstermion", "document-features", - "env_logger 0.10.0", + "env_logger", "futures-lite", "git-features", "git-repository", @@ -2212,9 +2195,9 @@ dependencies = [ [[package]] name = "insta" -version = "1.23.0" +version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48b08a091dfe5b09a6a9688c468fdd5b4396e92ce09e2eb932f0884b02788a4" +checksum = "f6f0f08b46e4379744de2ab67aa8f7de3ffd1da3e275adc41fcc82053ede46ff" dependencies = [ "console", "lazy_static", @@ -2249,7 +2232,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" dependencies = [ "libc", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -2266,9 +2249,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11b0d96e660696543b251e58030cf9787df56da39dab19ad60eae7353040917e" +checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" [[package]] name = "is-terminal" @@ -2279,7 +2262,7 @@ dependencies = [ "hermit-abi 0.2.6", "io-lifetimes", "rustix", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -2548,7 +2531,7 @@ dependencies = [ "libc", "log", "wasi", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -2584,15 +2567,16 @@ dependencies = [ [[package]] name = "nix" -version = "0.23.2" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" +checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" dependencies = [ + "autocfg", "bitflags", - "cc", "cfg-if", "libc", "memoffset 0.6.5", + "pin-utils", ] [[package]] @@ -2609,14 +2593,23 @@ dependencies = [ [[package]] name = "nom" -version = "7.1.1" +version = "7.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +checksum = "e5507769c4919c998e69e49c839d9dc6e693ede4cc4290d6ad8b41d4f09c548c" dependencies = [ "memchr", "minimal-lexical", ] +[[package]] +name = "nom8" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" +dependencies = [ + "memchr", +] + [[package]] name = "num-traits" version = "0.2.15" @@ -2725,9 +2718,9 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "papergrid" -version = "0.5.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453cf71f2a37af495a1a124bf30d4d7469cfbea58e9f2479be9d222396a518a2" +checksum = "1526bb6aa9f10ec339fb10360f22c57edf81d5678d0278e93bc12a47ffbe4b01" dependencies = [ "bytecount", "fnv", @@ -2785,7 +2778,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -2851,7 +2844,7 @@ dependencies = [ "libc", "log", "wepoll-ffi", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -3046,9 +3039,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" dependencies = [ "aho-corasick", "memchr", @@ -3082,7 +3075,7 @@ version = "0.11.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68cc60575865c7831548863cc02356512e3f1dc2f3f82cb837d7fc4cc8f3c97c" dependencies = [ - "base64", + "base64 0.13.1", "bytes", "encoding_rs", "futures-core", @@ -3161,7 +3154,7 @@ dependencies = [ "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -3182,7 +3175,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55" dependencies = [ - "base64", + "base64 0.13.1", ] [[package]] @@ -3208,12 +3201,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.20" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" dependencies = [ - "lazy_static", - "windows-sys 0.36.1", + "windows-sys", ] [[package]] @@ -3309,9 +3301,9 @@ dependencies = [ [[package]] name = "serial_test" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92761393ee4dc3ff8f4af487bd58f4307c9329bbedea02cac0089ad9c411e153" +checksum = "1c789ec87f4687d022a2405cf46e0cd6284889f1839de292cadeb6c6019506f2" dependencies = [ "dashmap", "futures", @@ -3323,11 +3315,10 @@ dependencies = [ [[package]] name = "serial_test_derive" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6f5d1c3087fb119617cff2966fe3808a80e5eb59a8c1601d5994d66f4346a5" +checksum = "b64f9e531ce97c88b4778aad0ceee079216071cffec6ac9b904277f8f92e7fe3" dependencies = [ - "proc-macro-error", "proc-macro2", "quote", "syn", @@ -3473,9 +3464,9 @@ dependencies = [ [[package]] name = "tabled" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5b2f8c37d26d87d2252187b0a45ea3cbf42baca10377c7e7eaaa2800fa9bf97" +checksum = "56c3ee73732ffceaea7b8f6b719ce3bb17f253fa27461ffeaf568ebd0cdb4b85" dependencies = [ "papergrid", "unicode-width", @@ -3596,9 +3587,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.23.0" +version = "1.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eab6d665857cc6ca78d6e80303a02cea7a7851e85dfbd77cbdc09bd129f1ef46" +checksum = "1d9f76183f91ecfb55e1d7d5602bd1d979e38a3a522fe900241cf195624d67ae" dependencies = [ "autocfg", "bytes", @@ -3608,7 +3599,7 @@ dependencies = [ "num_cpus", "pin-project-lite", "socket2", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -3655,15 +3646,22 @@ dependencies = [ "serde", ] +[[package]] +name = "toml_datetime" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808b51e57d0ef8f71115d8f3a01e7d3750d01c79cac4b3eda910f4389fdf92fd" + [[package]] name = "toml_edit" -version = "0.14.4" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5376256e44f2443f8896ac012507c19a012df0fe8758b55246ae51a2279db51f" +checksum = "a34cc558345efd7e88b9eda9626df2138b80bb46a7606f695e751c892bc7dac6" dependencies = [ - "combine", "indexmap", "itertools", + "nom8", + "toml_datetime", ] [[package]] @@ -3751,9 +3749,9 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "tui" @@ -4071,30 +4069,17 @@ dependencies = [ [[package]] name = "windows" -version = "0.40.0" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e30acc718a52fb130fec72b1cb5f55ffeeec9253e1b785e94db222178a6acaa1" +checksum = "04662ed0e3e5630dfa9b26e4cb823b817f1a9addda855d973a9458c236556244" dependencies = [ - "windows_aarch64_gnullvm 0.40.0", - "windows_aarch64_msvc 0.40.0", - "windows_i686_gnu 0.40.0", - "windows_i686_msvc 0.40.0", - "windows_x86_64_gnu 0.40.0", - "windows_x86_64_gnullvm 0.40.0", - "windows_x86_64_msvc 0.40.0", -] - -[[package]] -name = "windows-sys" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" -dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.0", ] [[package]] @@ -4103,21 +4088,15 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm 0.42.0", + "windows_aarch64_gnullvm", "windows_aarch64_msvc 0.42.0", "windows_i686_gnu 0.42.0", "windows_i686_msvc 0.42.0", "windows_x86_64_gnu 0.42.0", - "windows_x86_64_gnullvm 0.42.0", + "windows_x86_64_gnullvm", "windows_x86_64_msvc 0.42.0", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.40.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3caa4a1a16561b714323ca6b0817403738583033a6a92e04c5d10d4ba37ca10" - [[package]] name = "windows_aarch64_gnullvm" version = "0.42.0" @@ -4130,18 +4109,6 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d027175d00b01e0cbeb97d6ab6ebe03b12330a35786cbaca5252b1c4bf5d9b" -[[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.40.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "328973c62dfcc50fb1aaa8e7100676e0b642fe56bac6bafff3327902db843ab4" - [[package]] name = "windows_aarch64_msvc" version = "0.42.0" @@ -4154,18 +4121,6 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8793f59f7b8e8b01eda1a652b2697d87b93097198ae85f823b969ca5b89bba58" -[[package]] -name = "windows_i686_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" - -[[package]] -name = "windows_i686_gnu" -version = "0.40.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa5b09fad70f0df85dea2ac2a525537e415e2bf63ee31cf9b8e263645ee9f3c1" - [[package]] name = "windows_i686_gnu" version = "0.42.0" @@ -4178,18 +4133,6 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8602f6c418b67024be2996c512f5f995de3ba417f4c75af68401ab8756796ae4" -[[package]] -name = "windows_i686_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" - -[[package]] -name = "windows_i686_msvc" -version = "0.40.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a1ad4031c1a98491fa195d8d43d7489cb749f135f2e5c4eed58da094bd0d876" - [[package]] name = "windows_i686_msvc" version = "0.42.0" @@ -4202,30 +4145,12 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3d615f419543e0bd7d2b3323af0d86ff19cbc4f816e6453f36a2c2ce889c354" -[[package]] -name = "windows_x86_64_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.40.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520ff37edd72da8064b49d2281182898e17f0688ae9f4070bca27e4b5c162ac7" - [[package]] name = "windows_x86_64_gnu" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.40.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046e5b82215102c44fd75f488f1b9158973d02aa34d06ed85c23d6f5520a2853" - [[package]] name = "windows_x86_64_gnullvm" version = "0.42.0" @@ -4238,18 +4163,6 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11d95421d9ed3672c280884da53201a5c46b7b2765ca6faf34b0d71cf34a3561" -[[package]] -name = "windows_x86_64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.40.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0c9c6df55dd1bfa76e131cef44bdd8ec9c819ef3611f04dfe453fd5bfeda28" - [[package]] name = "windows_x86_64_msvc" version = "0.42.0" diff --git a/Cargo.toml b/Cargo.toml index d2667f1fa05..d3dabd8d32d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -97,7 +97,7 @@ futures-lite = { version = "1.12.0", optional = true, default-features = false, # for progress owo-colors = "3.5.0" -tabled = { version = "0.8.0", default-features = false } +tabled = { version = "0.10.0", default-features = false } document-features = { version = "0.2.0", optional = true } diff --git a/cargo-smart-release/Cargo.toml b/cargo-smart-release/Cargo.toml index cd9b6f93647..364aecfb438 100644 --- a/cargo-smart-release/Cargo.toml +++ b/cargo-smart-release/Cargo.toml @@ -27,13 +27,13 @@ cache-efficiency-debug = ["git-repository/cache-efficiency-debug"] git-repository = { version = "^0.32.0", path = "../git-repository", default-features = false, features = ["max-performance-safe"] } anyhow = "1.0.42" clap = { version = "3.2.5", features = ["derive", "cargo"] } -env_logger = { version = "0.9.0", default-features = false, features = ["humantime", "termcolor", "atty"] } +env_logger = { version = "0.10.0", default-features = false, features = ["humantime", "auto-color"] } cargo_metadata = "0.15.0" log = "0.4.14" -toml_edit = "0.14.0" +toml_edit = "0.17.1" semver = "1.0.4" crates-index = "0.18.9" -cargo_toml = "0.11.4" +cargo_toml = "0.14.0" nom = { version = "7", default-features = false, features = ["std"]} git-conventional = "0.12.0" time = "0.3.2" diff --git a/cargo-smart-release/src/changelog/section/from_history.rs b/cargo-smart-release/src/changelog/section/from_history.rs index aa3f4108a6a..16689718e69 100644 --- a/cargo-smart-release/src/changelog/section/from_history.rs +++ b/cargo-smart-release/src/changelog/section/from_history.rs @@ -133,7 +133,8 @@ impl Section { let version = crate::git::try_strip_tag_path(segment.head.name.as_ref()) .map(|tag_name| { - let package_name = (!is_top_level_package(&package.manifest_path, repo)).then(|| package.name.as_str()); + let package_name = + (!is_top_level_package(&package.manifest_path, repo)).then_some(package.name.as_str()); changelog::Version::Semantic( utils::parse_possibly_prefixed_tag_version(package_name, tag_name) .expect("here we always have a valid version as it passed a filter when creating it"), diff --git a/cargo-smart-release/src/command/changelog.rs b/cargo-smart-release/src/command/changelog.rs index aee74d78b87..ac2ff520241 100644 --- a/cargo-smart-release/src/command/changelog.rs +++ b/cargo-smart-release/src/command/changelog.rs @@ -20,7 +20,7 @@ pub fn changelog(opts: Options, crates: Vec) -> anyhow::Result<()> { no_links, .. } = opts; - let bump_spec = dependencies.then(|| BumpSpec::Auto).unwrap_or(BumpSpec::Keep); + let bump_spec = if dependencies { BumpSpec::Auto } else { BumpSpec::Keep }; let force_history_segmentation = false; let ctx = crate::Context::new(crates.clone(), force_history_segmentation, bump_spec, bump_spec)?; let crates: Vec<_> = { @@ -41,9 +41,11 @@ pub fn changelog(opts: Options, crates: Vec) -> anyhow::Result<()> { log::info!( "Skipping '{}' as it won't be published.{}", d.package.name, - (!dependencies) - .then(|| " Try not to specify --no-dependencies/--only.") - .unwrap_or("") + if !dependencies { + " Try not to specify --no-dependencies/--only." + } else { + "" + } ); } None @@ -114,7 +116,7 @@ pub fn changelog(opts: Options, crates: Vec) -> anyhow::Result<()> { if num_crates == 0 { anyhow::bail!( "The given crate{} {} didn't change and no changelog could be generated.", - (ctx.crate_names.len() != 1).then(|| "s").unwrap_or(""), + if ctx.crate_names.len() != 1 { "s" } else { "" }, ctx.crate_names .iter() .map(|c| format!("'{}'", c)) diff --git a/cargo-smart-release/src/command/release/manifest.rs b/cargo-smart-release/src/command/release/manifest.rs index fb221d12e33..99eaecca38d 100644 --- a/cargo-smart-release/src/command/release/manifest.rs +++ b/cargo-smart-release/src/command/release/manifest.rs @@ -263,7 +263,7 @@ fn preview_changelogs( "use --no-changelog-preview to disable or Ctrl-C to abort, or the 'changelog' subcommand."; let changelogs_with_changes = pending_changelogs .iter() - .filter_map(|(_, has_changes, lock)| (*has_changes).then(|| lock)) + .filter_map(|(_, has_changes, lock)| (*has_changes).then_some(lock)) .collect::>(); log::info!( "About to preview {} pending changelog(s), {}", diff --git a/cargo-smart-release/src/command/release/mod.rs b/cargo-smart-release/src/command/release/mod.rs index 9304c1978d1..5bcfa8e8d07 100644 --- a/cargo-smart-release/src/command/release/mod.rs +++ b/cargo-smart-release/src/command/release/mod.rs @@ -117,7 +117,7 @@ fn assure_crates_index_is_uptodate<'meta>( .find_map(|(d, b)| { b.latest_release .as_ref() - .and_then(|lr| (lr >= &b.next_release).then(|| d)) + .and_then(|lr| (lr >= &b.next_release).then_some(d)) }) { let mut index = crate::crates_index::Index::new_cargo_default()?; @@ -172,7 +172,7 @@ fn present_and_validate_dependencies( let skipped = all_skipped .iter() - .filter_map(|(name, has_adjustment, reason)| (!has_adjustment).then(|| (*name, reason))) + .filter_map(|(name, has_adjustment, reason)| (!has_adjustment).then_some((*name, reason))) .collect::>(); if !skipped.is_empty() { let skipped_len = skipped.len(); @@ -189,7 +189,7 @@ fn present_and_validate_dependencies( log::info!( "Will not publish or alter {} dependent crate{}: {}", skipped_len, - (skipped_len != 1).then(|| "s").unwrap_or(""), + if skipped_len != 1 { "s" } else { "" }, crates_by_reason .into_iter() .map(|(key, names)| format!( @@ -225,7 +225,7 @@ fn present_and_validate_dependencies( if let Some(latest_release) = bump .latest_release .as_ref() - .and_then(|lr| (*lr >= bump.next_release).then(|| lr)) + .and_then(|lr| (*lr >= bump.next_release).then_some(lr)) { let bump_flag = match dep.kind { dependency::Kind::UserSelection => "--bump ", @@ -329,7 +329,7 @@ fn present_and_validate_dependencies( }, ); for (cause, deps_and_bumps) in affected_crates_by_cause { - let plural_s = (deps_and_bumps.len() != 1).then(|| "s").unwrap_or(""); + let plural_s = if deps_and_bumps.len() != 1 { "s" } else { "" }; log::info!( "{} adjust {} manifest version{} due to breaking change in '{}': {}", will(dry_run), @@ -361,7 +361,7 @@ fn present_and_validate_dependencies( .collect::>(); if !crate_names_for_manifest_updates.is_empty() { let plural_s = (crate_names_for_manifest_updates.len() > 1) - .then(|| "s") + .then_some("s") .unwrap_or_default(); log::info!( "{} adjust version constraints in manifest{} of {} package{} as direct dependencies are changing: {}", diff --git a/cargo-smart-release/src/commit/message.rs b/cargo-smart-release/src/commit/message.rs index 219dcaf292e..4b22b6dc0e3 100644 --- a/cargo-smart-release/src/commit/message.rs +++ b/cargo-smart-release/src/commit/message.rs @@ -22,7 +22,7 @@ mod additions { .and_then(|p| { part_to_left .is_char_boundary(p + 1) - .then(|| p + 1) + .then_some(p + 1) .or_else(|| part_to_left[p..].chars().next().map(|c| p + c.len_utf8())) }) .unwrap_or(start); diff --git a/cargo-smart-release/src/git/mod.rs b/cargo-smart-release/src/git/mod.rs index 68e633963e8..ed460ae1369 100644 --- a/cargo-smart-release/src/git/mod.rs +++ b/cargo-smart-release/src/git/mod.rs @@ -40,7 +40,7 @@ pub fn change_since_last_release(package: &Package, ctx: &crate::Context) -> any // KEEP THIS IN SYNC with git::create_ref_history()! .or_else(|| (ctx.meta.workspace_members.len() != 1).then(|| Utf8Path::new("src"))) { - None => (current_commit != released_target).then(|| PackageChangeKind::ChangedOrNew), + None => (current_commit != released_target).then_some(PackageChangeKind::ChangedOrNew), Some(dir) => { let components = dir.components().map(component_to_bytes); let current_dir_id = current_commit @@ -58,7 +58,7 @@ pub fn change_since_last_release(package: &Package, ctx: &crate::Context) -> any .expect("path must exist as it was supposedly released there") .object_id(); - (released_dir_id != current_dir_id).then(|| PackageChangeKind::ChangedOrNew) + (released_dir_id != current_dir_id).then_some(PackageChangeKind::ChangedOrNew) } } } diff --git a/cargo-smart-release/src/traverse.rs b/cargo-smart-release/src/traverse.rs index a5ae065871a..f305638a846 100644 --- a/cargo-smart-release/src/traverse.rs +++ b/cargo-smart-release/src/traverse.rs @@ -297,11 +297,11 @@ fn forward_propagate_breaking_changes_for_manifest_updates<'meta>( ); } } else if is_pre_release_version(&dependant.version) || allow_auto_publish_of_stable_crates { - let kind = ctx - .crate_names - .contains(&dependant.name) - .then(|| dependency::Kind::UserSelection) - .unwrap_or(dependency::Kind::DependencyOrDependentOfUserSelection); + let kind = if ctx.crate_names.contains(&dependant.name) { + dependency::Kind::UserSelection + } else { + dependency::Kind::DependencyOrDependentOfUserSelection + }; let adjustment = dependency::VersionAdjustment::Breakage { bump, change: None, @@ -448,9 +448,11 @@ impl EditForPublish { } fn breaking_version_bump(ctx: &Context, package: &Package, bump_when_needed: bool) -> anyhow::Result { - let breaking_spec = is_pre_release_version(&package.version) - .then(|| BumpSpec::Minor) - .unwrap_or(BumpSpec::Major); + let breaking_spec = if is_pre_release_version(&package.version) { + BumpSpec::Minor + } else { + BumpSpec::Major + }; version::bump_package_with_spec(package, breaking_spec, ctx, bump_when_needed) } diff --git a/clippy.toml b/clippy.toml index 16caf02ee91..22fd4be7375 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -msrv = "1.60.0" +msrv = "1.64.0" diff --git a/etc/msrv-badge.svg b/etc/msrv-badge.svg index 4e327611bf4..fa117879cf4 100644 --- a/etc/msrv-badge.svg +++ b/etc/msrv-badge.svg @@ -1 +1 @@ -rustc: 1.59.0+rustc1.60.0+ +rustc: 1.59.0+rustc1.64.0+ diff --git a/git-attributes/src/match_group.rs b/git-attributes/src/match_group.rs index 57193c4b6d9..f7882bae5bd 100644 --- a/git-attributes/src/match_group.rs +++ b/git-attributes/src/match_group.rs @@ -78,7 +78,7 @@ impl Pattern for Attributes { Value::MacroAttributes(into_owned_assignments(assignments).ok()?), ), crate::parse::Kind::Pattern(p) => ( - (!p.is_negative()).then(|| p)?, + (!p.is_negative()).then_some(p)?, Value::Assignments(into_owned_assignments(assignments).ok()?), ), }; @@ -278,7 +278,7 @@ where }| { pattern .matches_repo_relative_path(relative_path, basename_start_pos, is_dir, case) - .then(|| Match { + .then_some(Match { pattern, value, source: self.source.as_deref(), @@ -307,7 +307,7 @@ where .find_map(|(idx, pm)| { pm.pattern .matches_repo_relative_path(relative_path, basename_start_pos, is_dir, case) - .then(|| idx) + .then_some(idx) }) } @@ -321,7 +321,7 @@ where relative_path.strip_prefix(base.as_slice())?.as_bstr(), basename_pos.and_then(|pos| { let pos = pos - base.len(); - (pos != 0).then(|| pos) + (pos != 0).then_some(pos) }), ), None => (relative_path, basename_pos), diff --git a/git-config/Cargo.toml b/git-config/Cargo.toml index 61ba1713638..1ab7bd91d3b 100644 --- a/git-config/Cargo.toml +++ b/git-config/Cargo.toml @@ -36,7 +36,7 @@ document-features = { version = "0.2.0", optional = true } [dev-dependencies] git-testtools = { path = "../tests/tools"} git-repository = { path = "../git-repository" } -serial_test = "0.9.0" +serial_test = "0.10.0" serde_derive = "1.0" criterion = "0.4.0" tempfile = "3.2.0" diff --git a/git-config/src/file/access/mutate.rs b/git-config/src/file/access/mutate.rs index b5c2504ffc3..4fbcbf0a110 100644 --- a/git-config/src/file/access/mutate.rs +++ b/git-config/src/file/access/mutate.rs @@ -348,6 +348,7 @@ impl<'event> File<'event> { } lhs.extend(rhs); } + #[allow(clippy::unnecessary_lazy_evaluations)] let our_last_section_before_append = insert_after.or_else(|| (self.section_id_counter != 0).then(|| SectionId(self.section_id_counter - 1))); diff --git a/git-config/src/file/access/read_only.rs b/git-config/src/file/access/read_only.rs index 5352e1982be..5681845bba5 100644 --- a/git-config/src/file/access/read_only.rs +++ b/git-config/src/file/access/read_only.rs @@ -166,7 +166,7 @@ impl<'event> File<'event> { let sections = &self.sections; move |id| { let s = §ions[&id]; - filter(s.meta()).then(|| s) + filter(s.meta()).then_some(s) } })) } @@ -258,7 +258,7 @@ impl<'event> File<'event> { .sections .get(&id) .expect("section doesn't have id from from lookup"); - filter(s.meta()).then(|| s) + filter(s.meta()).then_some(s) }) }) } diff --git a/git-config/src/file/includes/mod.rs b/git-config/src/file/includes/mod.rs index e95327f02ba..f4f11a4b02d 100644 --- a/git-config/src/file/includes/mod.rs +++ b/git-config/src/file/includes/mod.rs @@ -189,7 +189,7 @@ fn onbranch_matches( branch_name, git_glob::wildmatch::Mode::NO_MATCH_SLASH_LITERAL, ) - .then(|| ()) + .then_some(()) } fn gitdir_matches( diff --git a/git-config/src/file/init/comfort.rs b/git-config/src/file/init/comfort.rs index 4267b895b19..752c9e4aac1 100644 --- a/git-config/src/file/init/comfort.rs +++ b/git-config/src/file/init/comfort.rs @@ -31,7 +31,7 @@ impl File<'static> { .filter_map(|source| { let path = source .storage_location(&mut |name| std::env::var_os(name)) - .and_then(|p| p.is_file().then(|| p)) + .and_then(|p| p.is_file().then_some(p)) .map(|p| p.into_owned()); Metadata { diff --git a/git-config/src/file/mutable/section.rs b/git-config/src/file/mutable/section.rs index c3570ee3256..3c46cae6eca 100644 --- a/git-config/src/file/mutable/section.rs +++ b/git-config/src/file/mutable/section.rs @@ -71,7 +71,7 @@ impl<'a, 'event> SectionMut<'a, 'event> { if !bytes.peek().map_or(true, |b| b.is_ascii_whitespace()) { c.insert(0, b' '); } - c.extend(bytes.map(|b| (*b == b'\n').then(|| b' ').unwrap_or(*b))); + c.extend(bytes.map(|b| if *b == b'\n' { b' ' } else { *b })); c.into() }), })); diff --git a/git-config/src/file/section/body.rs b/git-config/src/file/section/body.rs index 91ed6c5a383..e44d29e645d 100644 --- a/git-config/src/file/section/body.rs +++ b/git-config/src/file/section/body.rs @@ -153,7 +153,7 @@ impl<'event> Body<'event> { // is included in the range let value_range = value_range.start..value_range.end + 1; let key_range = key_start..value_range.end; - (key_range, (value_range.start != key_start + 1).then(|| value_range)) + (key_range, (value_range.start != key_start + 1).then_some(value_range)) }) } } diff --git a/git-config/src/file/util.rs b/git-config/src/file/util.rs index f00ccc31e57..5c60f1fd5a0 100644 --- a/git-config/src/file/util.rs +++ b/git-config/src/file/util.rs @@ -61,7 +61,7 @@ impl<'event> File<'event> { section_order .iter() .enumerate() - .find_map(|(idx, id)| (*id == section_id).then(|| idx)) + .find_map(|(idx, id)| (*id == section_id).then_some(idx)) .expect("before-section exists") } }; diff --git a/git-config/src/file/write.rs b/git-config/src/file/write.rs index 71e3590b7f8..00ae29e909a 100644 --- a/git-config/src/file/write.rs +++ b/git-config/src/file/write.rs @@ -63,7 +63,7 @@ pub(crate) fn ends_with_newline(e: &[crate::parse::Event<'_>], nl: impl AsRef<[u e.iter() .rev() .take_while(|e| e.to_bstr_lossy().iter().all(|b| b.is_ascii_whitespace())) - .find_map(|e| e.to_bstr_lossy().contains_str(nl.as_ref()).then(|| true)) + .find_map(|e| e.to_bstr_lossy().contains_str(nl.as_ref()).then_some(true)) .unwrap_or(false) } diff --git a/git-config/src/parse/nom/mod.rs b/git-config/src/parse/nom/mod.rs index cc9048bf0c5..11d1dea6be5 100644 --- a/git-config/src/parse/nom/mod.rs +++ b/git-config/src/parse/nom/mod.rs @@ -400,7 +400,7 @@ fn value_impl<'a>(i: &'a [u8], dispatch: &mut impl FnMut(Event<'a>)) -> IResult< .iter() .enumerate() .rev() - .find_map(|(idx, b)| (!b.is_ascii_whitespace()).then(|| idx + 1)) + .find_map(|(idx, b)| (!b.is_ascii_whitespace()).then_some(idx + 1)) .unwrap_or(0); ( &i[value_end_no_trailing_whitespace..], diff --git a/git-config/src/parse/section/header.rs b/git-config/src/parse/section/header.rs index 9e70b76b3d0..341edcdd57e 100644 --- a/git-config/src/parse/section/header.rs +++ b/git-config/src/parse/section/header.rs @@ -48,14 +48,14 @@ pub fn is_valid_subsection(name: &BStr) -> bool { fn validated_subsection(name: Cow<'_, BStr>) -> Result, Error> { is_valid_subsection(name.as_ref()) - .then(|| name) + .then_some(name) .ok_or(Error::InvalidSubSection) } fn validated_name(name: Cow<'_, BStr>) -> Result, Error> { name.iter() .all(|b| b.is_ascii_alphanumeric() || *b == b'-') - .then(|| name) + .then_some(name) .ok_or(Error::InvalidName) } diff --git a/git-config/tests/file/init/from_paths/includes/conditional/mod.rs b/git-config/tests/file/init/from_paths/includes/conditional/mod.rs index d9bcc7d2b06..149e38d9d9a 100644 --- a/git-config/tests/file/init/from_paths/includes/conditional/mod.rs +++ b/git-config/tests/file/init/from_paths/includes/conditional/mod.rs @@ -142,8 +142,11 @@ fn options_with_git_dir(git_dir: &Path) -> init::Options<'_> { fn git_init(path: impl AsRef, bare: bool) -> crate::Result { Ok(git::ThreadSafeRepository::init_opts( path, - bare.then(|| git::create::Kind::Bare) - .unwrap_or(git::create::Kind::WithWorktree), + if bare { + git::create::Kind::Bare + } else { + git::create::Kind::WithWorktree + }, git::create::Options::default(), git::open::Options::isolated().config_overrides(["user.name=gitoxide", "user.email=gitoxide@localhost"]), )? diff --git a/git-date/tests/time/baseline.rs b/git-date/tests/time/baseline.rs index 4c3e13a212f..7df44580141 100644 --- a/git-date/tests/time/baseline.rs +++ b/git-date/tests/time/baseline.rs @@ -29,7 +29,7 @@ static BASELINE: Lazy> = Lazy::new(|| { map.insert( date_str.into(), Sample { - format_name: (!format_name.is_empty()).then(|| format_name), + format_name: (!format_name.is_empty()).then_some(format_name), exit_code, time_in_seconds_since_unix_epoch, }, diff --git a/git-discover/Cargo.toml b/git-discover/Cargo.toml index 078069fb34b..0b71baf6e14 100644 --- a/git-discover/Cargo.toml +++ b/git-discover/Cargo.toml @@ -22,7 +22,7 @@ thiserror = "1.0.26" [dev-dependencies] git-testtools = { path = "../tests/tools" } -serial_test = "0.9.0" +serial_test = "0.10.0" is_ci = "1.1.1" [target.'cfg(target_os = "macos")'.dev-dependencies] diff --git a/git-discover/src/upwards/mod.rs b/git-discover/src/upwards/mod.rs index d440fd0fa89..81eb70029b6 100644 --- a/git-discover/src/upwards/mod.rs +++ b/git-discover/src/upwards/mod.rs @@ -60,7 +60,7 @@ pub(crate) mod function { let filter_by_trust = |x: &Path| -> Result, Error> { let trust = Trust::from_path_ownership(x).map_err(|err| Error::CheckTrust { path: x.into(), err })?; - Ok((trust >= required_trust).then(|| (trust))) + Ok((trust >= required_trust).then_some(trust)) }; let max_height = if !ceiling_dirs.is_empty() { diff --git a/git-features/src/lib.rs b/git-features/src/lib.rs index f3c15e761fd..643320c0f1b 100644 --- a/git-features/src/lib.rs +++ b/git-features/src/lib.rs @@ -58,7 +58,7 @@ pub mod iter { break; } } - (!res.is_empty()).then(|| res) + (!res.is_empty()).then_some(res) } } } diff --git a/git-features/src/parallel/in_parallel.rs b/git-features/src/parallel/in_parallel.rs index c272781ee56..5eb3caa2188 100644 --- a/git-features/src/parallel/in_parallel.rs +++ b/git-features/src/parallel/in_parallel.rs @@ -165,7 +165,7 @@ where let mut state = new_thread_state(thread_id); while let Ok(input_index) = index.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| { - (x < input_len).then(|| x + 1) + (x < input_len).then_some(x + 1) }) { if stop_everything.load(Ordering::Relaxed) { diff --git a/git-glob/src/wildmatch.rs b/git-glob/src/wildmatch.rs index 059c267d9e1..1015279f20d 100644 --- a/git-glob/src/wildmatch.rs +++ b/git-glob/src/wildmatch.rs @@ -72,10 +72,7 @@ pub(crate) mod function { } } STAR => { - let mut match_slash = mode - .contains(Mode::NO_MATCH_SLASH_LITERAL) - .then(|| false) - .unwrap_or(true); + let mut match_slash = !mode.contains(Mode::NO_MATCH_SLASH_LITERAL); match p.next() { Some((next_p_idx, next_p_ch)) => { let next; diff --git a/git-index/src/extension/index_entry_offset_table.rs b/git-index/src/extension/index_entry_offset_table.rs index 9d0cab23d71..babf726102f 100644 --- a/git-index/src/extension/index_entry_offset_table.rs +++ b/git-index/src/extension/index_entry_offset_table.rs @@ -38,6 +38,6 @@ pub fn decode(data: &[u8]) -> Option> { pub fn find(extensions: &[u8], object_hash: git_hash::Kind) -> Option> { extension::Iter::new_without_checksum(extensions, object_hash)? - .find_map(|(sig, ext_data)| (sig == SIGNATURE).then(|| ext_data)) + .find_map(|(sig, ext_data)| (sig == SIGNATURE).then_some(ext_data)) .and_then(decode) } diff --git a/git-index/src/extension/tree/verify.rs b/git-index/src/extension/tree/verify.rs index 481760253ea..ec8894724b3 100644 --- a/git-index/src/extension/tree/verify.rs +++ b/git-index/src/extension/tree/verify.rs @@ -119,7 +119,7 @@ impl Tree { } let mut buf = Vec::new(); - let declared_entries = verify_recursive(self.id, &self.children, use_find.then(|| &mut buf), &mut find)?; + let declared_entries = verify_recursive(self.id, &self.children, use_find.then_some(&mut buf), &mut find)?; if let Some((actual, num_entries)) = declared_entries.zip(self.num_entries) { if actual > num_entries { return Err(Error::EntriesCount { diff --git a/git-index/src/extension/untracked_cache.rs b/git-index/src/extension/untracked_cache.rs index 6fa8af8a57c..47a466fcc41 100644 --- a/git-index/src/extension/untracked_cache.rs +++ b/git-index/src/extension/untracked_cache.rs @@ -58,14 +58,14 @@ pub fn decode(data: &[u8], object_hash: git_hash::Kind) -> Option Version { self.entries .iter() - .find_map(|e| e.flags.contains(entry::Flags::EXTENDED).then(|| Version::V3)) + .find_map(|e| e.flags.contains(entry::Flags::EXTENDED).then_some(Version::V3)) .unwrap_or(Version::V2) } } diff --git a/git-mailmap/src/parse.rs b/git-mailmap/src/parse.rs index 7c0f1e4c77e..6fb7374daec 100644 --- a/git-mailmap/src/parse.rs +++ b/git-mailmap/src/parse.rs @@ -110,7 +110,7 @@ fn parse_name_and_email( } let name = line[..start_bracket].trim().as_bstr(); let rest = line[start_bracket + closing_bracket + 2..].as_bstr(); - Ok(((!name.is_empty()).then(|| name), Some(email), rest)) + Ok(((!name.is_empty()).then_some(name), Some(email), rest)) } None => Ok((None, None, line)), } diff --git a/git-mailmap/src/snapshot/signature.rs b/git-mailmap/src/snapshot/signature.rs index 207dcbd83ce..406ab0f7db9 100644 --- a/git-mailmap/src/snapshot/signature.rs +++ b/git-mailmap/src/snapshot/signature.rs @@ -51,7 +51,7 @@ impl<'a> ResolvedSignature<'a> { ) -> Option { let new_email = new_email .map(|n| n.as_bstr()) - .or_else(|| (matched_email != current_email).then(|| matched_email)); + .or_else(|| (matched_email != current_email).then_some(matched_email)); match (new_email, new_name) { (None, None) => None, (new_email, new_name) => Some(ResolvedSignature { diff --git a/git-odb/src/store_impls/dynamic/handle.rs b/git-odb/src/store_impls/dynamic/handle.rs index 568eefacd75..8804ce878ce 100644 --- a/git-odb/src/store_impls/dynamic/handle.rs +++ b/git-odb/src/store_impls/dynamic/handle.rs @@ -44,7 +44,7 @@ impl<'a> IntraPackLookup<'a> { required_pack_index, } => index.lookup(id).and_then(|entry_index| { let (pack_index, pack_offset) = index.pack_id_and_pack_offset_at_index(entry_index); - (pack_index == *required_pack_index).then(|| pack_offset) + (pack_index == *required_pack_index).then_some(pack_offset) }), } } @@ -90,7 +90,7 @@ pub(crate) mod index_lookup { "BUG: multi-pack index must be set if this is a multi-pack, pack-indices seem unstable", ); Box::new(index.iter().filter_map(move |e| { - (e.pack_index == pack_index).then(|| git_pack::index::Entry { + (e.pack_index == pack_index).then_some(git_pack::index::Entry { oid: e.oid, pack_offset: e.pack_offset, crc32: None, diff --git a/git-odb/src/store_impls/dynamic/load_index.rs b/git-odb/src/store_impls/dynamic/load_index.rs index d7a37fbadcb..2c13df4d2ed 100644 --- a/git-odb/src/store_impls/dynamic/load_index.rs +++ b/git-odb/src/store_impls/dynamic/load_index.rs @@ -111,7 +111,7 @@ impl super::Store { match index .next_index_to_load .fetch_update(Ordering::SeqCst, Ordering::SeqCst, |current| { - (current != index.slot_indices.len()).then(|| current + 1) + (current != index.slot_indices.len()).then_some(current + 1) }) { Ok(slot_map_index) => { // This slot-map index is in bounds and was only given to us. @@ -230,7 +230,7 @@ impl super::Store { let indices_by_modification_time = Self::collect_indices_and_mtime_sorted_by_size( db_paths, index.slot_indices.len().into(), - self.use_multi_pack_index.then(|| self.object_hash), + self.use_multi_pack_index.then_some(self.object_hash), )?; let mut idx_by_index_path: BTreeMap<_, _> = index .slot_indices @@ -479,7 +479,7 @@ impl super::Store { (path != multi_index.path() && !index_names_in_multi_index .contains(&Path::new(path.file_name().expect("file name present")))) - .then(|| (Either::IndexPath(path), a, b)) + .then_some((Either::IndexPath(path), a, b)) }) .collect(); indices_not_in_multi_index.insert(0, (Either::MultiIndexFile(Arc::new(multi_index)), mtime, flen)); @@ -488,7 +488,7 @@ impl super::Store { indices_by_modification_time.extend( indices .into_iter() - .filter_map(|(p, a, b)| (!is_multipack_index(&p)).then(|| (Either::IndexPath(p), a, b))), + .filter_map(|(p, a, b)| (!is_multipack_index(&p)).then_some((Either::IndexPath(p), a, b))), ) } } diff --git a/git-pack/src/data/input/lookup_ref_delta_objects.rs b/git-pack/src/data/input/lookup_ref_delta_objects.rs index 166fe142eec..3f8f5940033 100644 --- a/git-pack/src/data/input/lookup_ref_delta_objects.rs +++ b/git-pack/src/data/input/lookup_ref_delta_objects.rs @@ -155,7 +155,8 @@ where self.inserted_entry_length_at_offset .get(maybe_index_of_actual_entry) .and_then(|c| { - (c.pack_offset == base_pack_offset).then(|| maybe_index_of_actual_entry) + (c.pack_offset == base_pack_offset) + .then_some(maybe_index_of_actual_entry) }) .unwrap_or(index) }; diff --git a/git-pack/src/data/output/entry/iter_from_counts.rs b/git-pack/src/data/output/entry/iter_from_counts.rs index 53a101c01a5..53bf6862c6b 100644 --- a/git-pack/src/data/output/entry/iter_from_counts.rs +++ b/git-pack/src/data/output/entry/iter_from_counts.rs @@ -178,7 +178,7 @@ where count, counts_in_pack, base_index_offset, - allow_thin_pack.then(|| { + allow_thin_pack.then_some({ |pack_id, base_offset| { let (cached_pack_id, cache) = pack_offsets_to_id.get_or_insert_with(|| { db.pack_offsets_and_oid(pack_id) diff --git a/git-pack/src/multi_index/chunk.rs b/git-pack/src/multi_index/chunk.rs index 80982bfecff..58083c02bf5 100644 --- a/git-pack/src/multi_index/chunk.rs +++ b/git-pack/src/multi_index/chunk.rs @@ -244,7 +244,7 @@ pub mod large_offsets { } } - needs_large_offsets.then(|| num_large_offsets) + needs_large_offsets.then_some(num_large_offsets) } /// Returns true if the `offsets` range seems to be properly aligned for the data we expect. pub fn is_valid(offset: &Range) -> bool { @@ -258,7 +258,7 @@ pub mod large_offsets { ) -> std::io::Result<()> { for offset in sorted_entries .iter() - .filter_map(|e| (e.pack_offset > LARGE_OFFSET_THRESHOLD).then(|| e.pack_offset)) + .filter_map(|e| (e.pack_offset > LARGE_OFFSET_THRESHOLD).then_some(e.pack_offset)) { out.write_all(&offset.to_be_bytes())?; num_large_offsets = num_large_offsets diff --git a/git-pack/src/multi_index/init.rs b/git-pack/src/multi_index/init.rs index ca1afb22d24..68d3bafeb56 100644 --- a/git-pack/src/multi_index/init.rs +++ b/git-pack/src/multi_index/init.rs @@ -104,7 +104,7 @@ impl TryFrom<&Path> for File { let lookup = chunks.validated_usize_offset_by_id(chunk::lookup::ID, |offset| { chunk::lookup::is_valid(&offset, object_hash, num_objects) - .then(|| offset) + .then_some(offset) .ok_or(Error::InvalidChunkSize { id: chunk::lookup::ID, message: "The chunk with alphabetically ordered object ids doesn't have the correct size", @@ -112,7 +112,7 @@ impl TryFrom<&Path> for File { })??; let offsets = chunks.validated_usize_offset_by_id(chunk::offsets::ID, |offset| { chunk::offsets::is_valid(&offset, num_objects) - .then(|| offset) + .then_some(offset) .ok_or(Error::InvalidChunkSize { id: chunk::offsets::ID, message: "The chunk with offsets into the pack doesn't have the correct size", @@ -121,7 +121,7 @@ impl TryFrom<&Path> for File { let large_offsets = chunks .validated_usize_offset_by_id(chunk::large_offsets::ID, |offset| { chunk::large_offsets::is_valid(&offset) - .then(|| offset) + .then_some(offset) .ok_or(Error::InvalidChunkSize { id: chunk::large_offsets::ID, message: "The chunk with large offsets into the pack doesn't have the correct size", diff --git a/git-pack/src/verify.rs b/git-pack/src/verify.rs index cab45c3c23b..4bde578490e 100644 --- a/git-pack/src/verify.rs +++ b/git-pack/src/verify.rs @@ -22,7 +22,7 @@ pub mod checksum { pub fn fan(data: &[u32]) -> Option { data.windows(2) .enumerate() - .find_map(|(win_index, v)| (v[0] > v[1]).then(|| win_index)) + .find_map(|(win_index, v)| (v[0] > v[1]).then_some(win_index)) } /// Calculate the hash of the given kind by trying to read the file from disk at `data_path` or falling back on the mapped content in `data`. diff --git a/git-prompt/Cargo.toml b/git-prompt/Cargo.toml index b469bf02a69..42693c905d7 100644 --- a/git-prompt/Cargo.toml +++ b/git-prompt/Cargo.toml @@ -23,5 +23,5 @@ nix = { version = "0.26.1", default-features = false, features = ["term"] } [dev-dependencies] git-testtools = { path = "../tests/tools"} -serial_test = "0.9.0" -expectrl = "0.5.2" +serial_test = "0.10.0" +expectrl = "0.6.0" diff --git a/git-prompt/src/types.rs b/git-prompt/src/types.rs index 49ea309f399..8b8b6678f20 100644 --- a/git-prompt/src/types.rs +++ b/git-prompt/src/types.rs @@ -75,7 +75,7 @@ impl Options<'_> { .then(|| { std::env::var_os("GIT_TERMINAL_PROMPT") .and_then(|val| git_config_value::Boolean::try_from(val).ok()) - .and_then(|allow| (!allow.0).then(|| Mode::Disable)) + .and_then(|allow| (!allow.0).then_some(Mode::Disable)) }) .flatten() .unwrap_or(self.mode); diff --git a/git-protocol/tests/fetch/response.rs b/git-protocol/tests/fetch/response.rs index 842467f78da..5182916183e 100644 --- a/git-protocol/tests/fetch/response.rs +++ b/git-protocol/tests/fetch/response.rs @@ -127,7 +127,7 @@ mod v2 { for keepalive in [false, true] { let fixture = format!( "v2/clone-only{}.response", - keepalive.then(|| "-with-keepalive").unwrap_or_default() + keepalive.then_some("-with-keepalive").unwrap_or_default() ); let mut provider = mock_reader(&fixture); let mut reader = provider.as_read_without_sidebands(); diff --git a/git-protocol/tests/fetch/v1.rs b/git-protocol/tests/fetch/v1.rs index 92632d67e8d..09af3818e64 100644 --- a/git-protocol/tests/fetch/v1.rs +++ b/git-protocol/tests/fetch/v1.rs @@ -12,7 +12,7 @@ async fn clone() -> crate::Result { let mut dlg = CloneDelegate::default(); let fixture = format!( "v1/clone{}.response", - with_keepalive.then(|| "-with-keepalive").unwrap_or_default() + with_keepalive.then_some("-with-keepalive").unwrap_or_default() ); git_protocol::fetch( transport( diff --git a/git-ref/src/store/file/transaction/prepare.rs b/git-ref/src/store/file/transaction/prepare.rs index 8e981ce1790..c8d38619b76 100644 --- a/git-ref/src/store/file/transaction/prepare.rs +++ b/git-ref/src/store/file/transaction/prepare.rs @@ -417,7 +417,7 @@ fn possibly_adjust_name_for_prefixes(name: &FullNameRef) -> Option { MainRef | LinkedRef { .. } => sn .category() .map_or(false, |cat| !cat.is_worktree_private()) - .then(|| sn), + .then_some(sn), } .map(|n| n.to_owned()) } diff --git a/git-refspec/src/match_group/mod.rs b/git-refspec/src/match_group/mod.rs index 820d2664a26..f68b691d392 100644 --- a/git-refspec/src/match_group/mod.rs +++ b/git-refspec/src/match_group/mod.rs @@ -78,7 +78,7 @@ impl<'a> MatchGroup<'a> { for matcher in matchers .into_iter() .zip(self.specs.iter()) - .filter_map(|(m, spec)| m.and_then(|m| (spec.mode == Mode::Negative).then(|| m))) + .filter_map(|(m, spec)| m.and_then(|m| (spec.mode == Mode::Negative).then_some(m))) { out.retain(|m| match m.lhs { SourceRef::ObjectId(_) => true, diff --git a/git-refspec/src/match_group/util.rs b/git-refspec/src/match_group/util.rs index 09bb3755420..522ce2bbdfa 100644 --- a/git-refspec/src/match_group/util.rs +++ b/git-refspec/src/match_group/util.rs @@ -70,7 +70,7 @@ impl<'a> Needle<'a> { } } Needle::PartialName(name) => crate::spec::expand_partial_name(name, |expanded| { - (expanded == item.full_ref_name).then(|| Match::Normal) + (expanded == item.full_ref_name).then_some(Match::Normal) }) .unwrap_or(Match::None), Needle::Glob { name, asterisk_pos } => { diff --git a/git-refspec/src/match_group/validate.rs b/git-refspec/src/match_group/validate.rs index 783ef4c5d15..097a6458708 100644 --- a/git-refspec/src/match_group/validate.rs +++ b/git-refspec/src/match_group/validate.rs @@ -72,9 +72,11 @@ impl std::fmt::Display for Error { f, "Found {} {} the refspec mapping to be used: \n\t{}", self.issues.len(), - (self.issues.len() == 1) - .then(|| "issue that prevents") - .unwrap_or("issues that prevent"), + if self.issues.len() == 1 { + "issue that prevents" + } else { + "issues that prevent" + }, self.issues .iter() .map(|issue| issue.to_string()) diff --git a/git-refspec/src/parse.rs b/git-refspec/src/parse.rs index 93c43d3064e..161f99a59aa 100644 --- a/git-refspec/src/parse.rs +++ b/git-refspec/src/parse.rs @@ -107,7 +107,7 @@ pub(crate) mod function { } } None => { - let src = (!spec.is_empty()).then(|| spec); + let src = (!spec.is_empty()).then_some(spec); if Operation::Fetch == operation && mode != Mode::Negative && src.is_none() { return Ok(fetch_head_only(mode)); } else { diff --git a/git-refspec/src/spec.rs b/git-refspec/src/spec.rs index a609e41dc6f..fe7589e5d67 100644 --- a/git-refspec/src/spec.rs +++ b/git-refspec/src/spec.rs @@ -140,7 +140,7 @@ impl<'a> RefSpecRef<'a> { let suffix = source.strip_prefix(b"refs/")?; let slash_pos = suffix.find_byte(b'/')?; let prefix = source[..="refs/".len() + slash_pos].as_bstr(); - (!prefix.contains(&b'*')).then(|| prefix) + (!prefix.contains(&b'*')).then_some(prefix) } /// As opposed to [`prefix()`][Self::prefix], if the latter is `None` it will expand to all possible prefixes and place them in `out`. diff --git a/git-repository/Cargo.toml b/git-repository/Cargo.toml index 403c343dd5c..0b61d861eb8 100644 --- a/git-repository/Cargo.toml +++ b/git-repository/Cargo.toml @@ -7,7 +7,7 @@ version = "0.32.0" authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "CHANGELOG.md"] -rust-version = "1.60" +rust-version = "1.64" [lib] doctest = false @@ -151,7 +151,7 @@ git-testtools = { path = "../tests/tools" } is_ci = "1.1.1" anyhow = "1" walkdir = "2.3.2" -serial_test = "0.9.0" +serial_test = "0.10.0" async-std = { version = "1.12.0", features = ["attributes"] } [package.metadata.docs.rs] diff --git a/git-repository/src/config/cache/incubate.rs b/git-repository/src/config/cache/incubate.rs index d9176f52eef..9fdcfe1caae 100644 --- a/git-repository/src/config/cache/incubate.rs +++ b/git-repository/src/config/cache/incubate.rs @@ -37,7 +37,7 @@ impl StageOne { .value::("core", None, "repositoryFormatVersion") .map_or(0, |v| v.to_decimal().unwrap_or_default()); let object_hash = (repo_format_version != 1) - .then(|| Ok(git_hash::Kind::Sha1)) + .then_some(Ok(git_hash::Kind::Sha1)) .or_else(|| { config.string("extensions", None, "objectFormat").map(|format| { if format.as_ref().eq_ignore_ascii_case(b"sha1") { diff --git a/git-repository/src/config/cache/util.rs b/git-repository/src/config/cache/util.rs index f17cfcdf78f..09f963cd7fa 100644 --- a/git-repository/src/config/cache/util.rs +++ b/git-repository/src/config/cache/util.rs @@ -46,8 +46,11 @@ pub(crate) fn query_refupdates( .boolean("core", None, "logAllRefUpdates") .and_then(|b| b.ok()) .map(|b| { - b.then(|| git_ref::store::WriteReflog::Normal) - .unwrap_or(git_ref::store::WriteReflog::Disable) + if b { + git_ref::store::WriteReflog::Normal + } else { + git_ref::store::WriteReflog::Disable + } }) { Some(val) => Ok(Some(val)), None => match config.string("core", None, "logAllRefUpdates") { @@ -97,10 +100,10 @@ pub(crate) fn reflog_or_default( config_reflog: Option, has_worktree: bool, ) -> git_ref::store::WriteReflog { - config_reflog.unwrap_or_else(|| { - has_worktree - .then(|| git_ref::store::WriteReflog::Normal) - .unwrap_or(git_ref::store::WriteReflog::Disable) + config_reflog.unwrap_or(if has_worktree { + git_ref::store::WriteReflog::Normal + } else { + git_ref::store::WriteReflog::Disable }) } diff --git a/git-repository/src/config/snapshot/credential_helpers.rs b/git-repository/src/config/snapshot/credential_helpers.rs index f248911e7bf..b63789b5cd7 100644 --- a/git-repository/src/config/snapshot/credential_helpers.rs +++ b/git-repository/src/config/snapshot/credential_helpers.rs @@ -73,7 +73,7 @@ impl Snapshot<'_> { let ports = is_http .then(|| (pattern.port_or_default(), url.port_or_default())) .unwrap_or((pattern.port, url.port)); - let path = (!(is_http && pattern.path_is_root())).then(|| &pattern.path); + let path = (!(is_http && pattern.path_is_root())).then_some(&pattern.path); if !path.map_or(true, |path| path == &url.path) { return None; @@ -81,7 +81,8 @@ impl Snapshot<'_> { if pattern.user().is_some() && pattern.user() != url.user() { return None; } - (scheme == &url.scheme && host_matches(host, url.host()) && ports.0 == ports.1).then(|| section) + (scheme == &url.scheme && host_matches(host, url.host()) && ports.0 == ports.1) + .then_some(section) }), None => Some(section), }; diff --git a/git-repository/src/create.rs b/git-repository/src/create.rs index 10f3d4bcec9..c28a23d8970 100644 --- a/git-repository/src/create.rs +++ b/git-repository/src/create.rs @@ -229,8 +229,11 @@ pub fn into( Ok(git_discover::repository::Path::from_dot_git_dir( dot_git, - bare.then(|| git_discover::repository::Kind::Bare) - .unwrap_or(git_discover::repository::Kind::WorkTree { linked_git_dir: None }), + if bare { + git_discover::repository::Kind::Bare + } else { + git_discover::repository::Kind::WorkTree { linked_git_dir: None } + }, std::env::current_dir()?, ) .expect("by now the `dot_git` dir is valid as we have accessed it")) diff --git a/git-repository/src/remote/connection/fetch/mod.rs b/git-repository/src/remote/connection/fetch/mod.rs index 85f5f75b321..65ac1864211 100644 --- a/git-repository/src/remote/connection/fetch/mod.rs +++ b/git-repository/src/remote/connection/fetch/mod.rs @@ -171,7 +171,7 @@ where /// /// This works by not actually fetching the pack after negotiating it, nor will refs be updated. pub fn with_dry_run(mut self, enabled: bool) -> Self { - self.dry_run = enabled.then(|| DryRun::Yes).unwrap_or(DryRun::No); + self.dry_run = if enabled { DryRun::Yes } else { DryRun::No }; self } @@ -180,7 +180,11 @@ where /// This improves performance and allows case-sensitive filesystems to deal with ref names that would otherwise /// collide. pub fn with_write_packed_refs_only(mut self, enabled: bool) -> Self { - self.write_packed_refs = enabled.then(|| WritePackedRefs::Only).unwrap_or(WritePackedRefs::Never); + self.write_packed_refs = if enabled { + WritePackedRefs::Only + } else { + WritePackedRefs::Never + }; self } diff --git a/git-repository/src/remote/save.rs b/git-repository/src/remote/save.rs index a8ce7cef400..d4f800aa158 100644 --- a/git-repository/src/remote/save.rs +++ b/git-repository/src/remote/save.rs @@ -45,7 +45,7 @@ impl Remote<'_> { .to_owned(), })?; if let Some(section_ids) = config.sections_and_ids_by_name("remote").map(|it| { - it.filter_map(|(s, id)| (s.header().subsection_name() == Some(name.as_bstr())).then(|| id)) + it.filter_map(|(s, id)| (s.header().subsection_name() == Some(name.as_bstr())).then_some(id)) .collect::>() }) { let mut sections_to_remove = Vec::new(); diff --git a/git-repository/src/remote/url/rewrite.rs b/git-repository/src/remote/url/rewrite.rs index 8f2e9320c09..85aec4dc01e 100644 --- a/git-repository/src/remote/url/rewrite.rs +++ b/git-repository/src/remote/url/rewrite.rs @@ -70,7 +70,7 @@ impl Rewrite { None } else { let mut url = url.to_bstring(); - self.rewrite_url_in_place(&mut url, direction).then(|| url) + self.rewrite_url_in_place(&mut url, direction).then_some(url) } } diff --git a/git-repository/src/repository/config/transport.rs b/git-repository/src/repository/config/transport.rs index 34b9b450403..f553455afd7 100644 --- a/git-repository/src/repository/config/transport.rs +++ b/git-repository/src/repository/config/transport.rs @@ -235,8 +235,11 @@ impl crate::Repository { .transpose() .with_leniency(lenient)? { - val.then(|| http::options::FollowRedirects::All) - .unwrap_or(http::options::FollowRedirects::None) + if val { + http::options::FollowRedirects::All + } else { + http::options::FollowRedirects::None + } } else { http::options::FollowRedirects::Initial }; diff --git a/git-repository/src/revision/spec/parse/delegate/mod.rs b/git-repository/src/revision/spec/parse/delegate/mod.rs index 15d908aa71b..2ada9d0b824 100644 --- a/git-repository/src/revision/spec/parse/delegate/mod.rs +++ b/git-repository/src/revision/spec/parse/delegate/mod.rs @@ -116,7 +116,7 @@ impl<'repo> parse::Delegate for Delegate<'repo> { self.follow_refs_to_objects_if_needed(); self.disambiguate_objects_by_fallback_hint( self.kind_implies_committish() - .then(|| ObjectKindHint::Committish) + .then_some(ObjectKindHint::Committish) .or(self.opts.object_kind_hint), ); } diff --git a/git-repository/src/worktree/mod.rs b/git-repository/src/worktree/mod.rs index 6cc2280d847..4c895c5a3bd 100644 --- a/git-repository/src/worktree/mod.rs +++ b/git-repository/src/worktree/mod.rs @@ -63,7 +63,7 @@ pub(crate) fn id(git_dir: &std::path::Path, has_common_dir: bool) -> Option<&BSt let candidate = git_path::os_str_into_bstr(git_dir.file_name().expect("at least one directory level")) .expect("no illformed UTF-8"); let maybe_worktrees = git_dir.parent()?; - (maybe_worktrees.file_name()?.to_str()? == "worktrees").then(|| candidate) + (maybe_worktrees.file_name()?.to_str()? == "worktrees").then_some(candidate) } /// @@ -130,7 +130,7 @@ pub mod excludes { let case = repo .config .ignore_case - .then(|| git_glob::pattern::Case::Fold) + .then_some(git_glob::pattern::Case::Fold) .unwrap_or_default(); let mut buf = Vec::with_capacity(512); let excludes_file = match repo.config.excludes_file().transpose()? { diff --git a/git-repository/tests/revision/spec/from_bytes/util.rs b/git-repository/tests/revision/spec/from_bytes/util.rs index 4ec8a6df975..8733517fe03 100644 --- a/git-repository/tests/revision/spec/from_bytes/util.rs +++ b/git-repository/tests/revision/spec/from_bytes/util.rs @@ -45,7 +45,7 @@ static BASELINE: Lazy Option<(&BStr, delegate::PrefixHint<'_>) rest.iter().all(|b| b.is_ascii_hexdigit()).then(|| rest.as_bstr()) })?; - let candidate = iter.clone().any(|token| !token.is_empty()).then(|| candidate); + let candidate = iter.clone().any(|token| !token.is_empty()).then_some(candidate); let hint = iter .next() .and_then(|gen| gen.to_str().ok().and_then(|gen| usize::from_str(gen).ok())) @@ -235,7 +235,7 @@ fn short_describe_prefix(name: &BStr) -> Option<&BStr> { let candidate = iter .next() .and_then(|prefix| prefix.iter().all(|b| b.is_ascii_hexdigit()).then(|| prefix.as_bstr())); - (iter.count() == 1).then(|| candidate).flatten() + (iter.count() == 1).then_some(candidate).flatten() } type InsideParensRestConsumed<'a> = (std::borrow::Cow<'a, BStr>, &'a BStr, usize); @@ -388,7 +388,7 @@ where try_set_prefix(delegate, prefix, hint) }) .or_else(|| { - name.is_empty().then(|| ()).or_else(|| { + name.is_empty().then_some(()).or_else(|| { #[allow(clippy::let_unit_value)] { let res = delegate.find_ref(name)?; diff --git a/git-sec/Cargo.toml b/git-sec/Cargo.toml index a716d16f10e..7c3d5ce2880 100644 --- a/git-sec/Cargo.toml +++ b/git-sec/Cargo.toml @@ -27,7 +27,7 @@ libc = "0.2.123" [target.'cfg(windows)'.dependencies] git-path = { version = "^0.7.0", path = "../git-path" } dirs = "4" -windows = { version = "0.40.0", features = [ +windows = { version = "0.43.0", features = [ "Win32_Foundation", "Win32_Security_Authorization", "Win32_Storage_FileSystem", diff --git a/git-sec/src/identity.rs b/git-sec/src/identity.rs index 25df953364d..6452c4ce7a2 100644 --- a/git-sec/src/identity.rs +++ b/git-sec/src/identity.rs @@ -119,10 +119,18 @@ mod impl_ { let mut buffer_size = 0; let mut buffer = Vec::::new(); - GetTokenInformation(token, TokenOwner, None, &mut buffer_size); + GetTokenInformation(token, TokenOwner, None, 0, &mut buffer_size); if buffer_size != 0 { buffer.resize(buffer_size as usize, 0); - if GetTokenInformation(token, TokenOwner, Some(buffer.as_mut_slice()), &mut buffer_size).as_bool() { + if GetTokenInformation( + token, + TokenOwner, + Some(buffer.as_mut_ptr() as *mut std::ffi::c_void), + buffer_size, + &mut buffer_size, + ) + .as_bool() + { let token_owner = buffer.as_ptr() as *const TOKEN_OWNER; let token_owner = (*token_owner).Owner; diff --git a/git-sec/src/trust.rs b/git-sec/src/trust.rs index cee480d7661..274c5b7807d 100644 --- a/git-sec/src/trust.rs +++ b/git-sec/src/trust.rs @@ -3,9 +3,11 @@ use crate::Trust; impl Trust { /// Derive `Full` trust if `path` is owned by the user executing the current process, or `Reduced` trust otherwise. pub fn from_path_ownership(path: impl AsRef) -> std::io::Result { - Ok(crate::identity::is_path_owned_by_current_user(path.as_ref())? - .then(|| Trust::Full) - .unwrap_or(Trust::Reduced)) + Ok(if crate::identity::is_path_owned_by_current_user(path.as_ref())? { + Trust::Full + } else { + Trust::Reduced + }) } } diff --git a/git-tempfile/src/fs/remove_dir.rs b/git-tempfile/src/fs/remove_dir.rs index b27903267d4..6f907d66e34 100644 --- a/git-tempfile/src/fs/remove_dir.rs +++ b/git-tempfile/src/fs/remove_dir.rs @@ -51,7 +51,7 @@ impl<'a> Iterator for Iter<'a> { }, }; self.cursor = match dir.parent() { - Some(parent) => (parent != self.boundary).then(|| parent), + Some(parent) => (parent != self.boundary).then_some(parent), None => { unreachable!("directory {:?} ran out of parents, this really shouldn't happen before hitting the boundary {:?}", dir, self.boundary) } diff --git a/git-transport/Cargo.toml b/git-transport/Cargo.toml index ff94a8fea72..bc86e703b1b 100644 --- a/git-transport/Cargo.toml +++ b/git-transport/Cargo.toml @@ -70,7 +70,7 @@ futures-lite = { version = "1.12.0", optional = true } pin-project-lite = { version = "0.2.6", optional = true } # for http-client -base64 = { version = "0.13.0", optional = true } +base64 = { version = "0.21.0", optional = true } # for http-client-curl. Additional configuration should be performed on higher levels of the dependency tree. curl = { version = "0.4", optional = true } diff --git a/git-transport/src/client/blocking_io/file.rs b/git-transport/src/client/blocking_io/file.rs index 2fa6d5ad2b1..c580cf9e28b 100644 --- a/git-transport/src/client/blocking_io/file.rs +++ b/git-transport/src/client/blocking_io/file.rs @@ -91,7 +91,7 @@ impl client::TransportWithoutIO for SpawnProcessOnDemand { fn set_identity(&mut self, identity: git_sec::identity::Account) -> Result<(), client::Error> { if self.url.scheme == git_url::Scheme::Ssh { self.url - .set_user((!identity.username.is_empty()).then(|| identity.username)); + .set_user((!identity.username.is_empty()).then_some(identity.username)); Ok(()) } else { Err(client::Error::AuthenticationUnsupported) diff --git a/git-transport/src/client/blocking_io/http/curl/remote.rs b/git-transport/src/client/blocking_io/http/curl/remote.rs index fe56ae8c413..14bfe24d2ef 100644 --- a/git-transport/src/client/blocking_io/http/curl/remote.rs +++ b/git-transport/src/client/blocking_io/http/curl/remote.rs @@ -308,9 +308,11 @@ pub fn new() -> ( authenticate.lock().expect("no panics in other threads")(action.erase()).ok(); } let err = Err(io::Error::new( - curl_is_spurious(&err) - .then(|| std::io::ErrorKind::ConnectionReset) - .unwrap_or(std::io::ErrorKind::Other), + if curl_is_spurious(&err) { + std::io::ErrorKind::ConnectionReset + } else { + std::io::ErrorKind::Other + }, err, )); handler.receive_body.take(); diff --git a/git-transport/src/client/blocking_io/http/mod.rs b/git-transport/src/client/blocking_io/http/mod.rs index bfc0c2c170d..e3827ddc5ba 100644 --- a/git-transport/src/client/blocking_io/http/mod.rs +++ b/git-transport/src/client/blocking_io/http/mod.rs @@ -1,3 +1,4 @@ +use base64::Engine; use std::{ any::Any, borrow::Cow, @@ -8,7 +9,7 @@ use std::{ use bstr::BStr; use git_packetline::PacketLineRef; -pub use traits::{Error, GetResponse, Http, PostResponse}; +pub use traits::{Error, GetResponse, Http, PostBodyDataKind, PostResponse}; use crate::{ client::{ @@ -269,7 +270,7 @@ impl Transport { } headers.push(Cow::Owned(format!( "Authorization: Basic {}", - base64::encode(format!("{}:{}", username, password)) + base64::engine::general_purpose::STANDARD.encode(format!("{}:{}", username, password)) ))) } Ok(()) diff --git a/git-transport/src/client/blocking_io/ssh/mod.rs b/git-transport/src/client/blocking_io/ssh/mod.rs index dc07cae8c2d..97ba4c192f7 100644 --- a/git-transport/src/client/blocking_io/ssh/mod.rs +++ b/git-transport/src/client/blocking_io/ssh/mod.rs @@ -97,7 +97,7 @@ pub fn connect( let ssh_cmd = options.ssh_command(); let mut kind = options.kind.unwrap_or_else(|| ProgramKind::from(ssh_cmd)); if options.kind.is_none() && kind == ProgramKind::Simple { - kind = std::process::Command::from( + kind = if std::process::Command::from( git_command::prepare(ssh_cmd) .stderr(Stdio::null()) .stdout(Stdio::null()) @@ -109,8 +109,11 @@ pub fn connect( .status() .ok() .map_or(false, |status| status.success()) - .then(|| ProgramKind::Ssh) - .unwrap_or(ProgramKind::Simple); + { + ProgramKind::Ssh + } else { + ProgramKind::Simple + }; } let path = git_url::expand_path::for_shell(url.path.clone()); diff --git a/git-url/src/parse.rs b/git-url/src/parse.rs index f200b94120b..7ab9de8d0a5 100644 --- a/git-url/src/parse.rs +++ b/git-url/src/parse.rs @@ -40,7 +40,7 @@ fn guess_protocol(url: &[u8]) -> Option<&str> { "ssh" } else { url.get(colon_pos + 1..).and_then(|from_colon| { - (from_colon.contains(&b'/') || from_colon.contains(&b'\\')).then(|| "file") + (from_colon.contains(&b'/') || from_colon.contains(&b'\\')).then_some("file") })? } } diff --git a/git-worktree/src/fs/cache/mod.rs b/git-worktree/src/fs/cache/mod.rs index 45926db9894..703ff3c8a19 100644 --- a/git-worktree/src/fs/cache/mod.rs +++ b/git-worktree/src/fs/cache/mod.rs @@ -129,7 +129,7 @@ impl Cache { self.at_path( relative_path, - is_dir.or_else(|| relative.ends_with_str("/").then(|| true)), + is_dir.or_else(|| relative.ends_with_str("/").then_some(true)), // is_dir, find, ) diff --git a/git-worktree/src/fs/cache/state.rs b/git-worktree/src/fs/cache/state.rs index 2690fb2e3a7..0533de69929 100644 --- a/git-worktree/src/fs/cache/state.rs +++ b/git-worktree/src/fs/cache/state.rs @@ -275,7 +275,7 @@ impl State { Case::Sensitive => basename == t.0, Case::Fold => basename.eq_ignore_ascii_case(t.0), } - .then(|| t.1) + .then_some(t.1) })?; // See https://github.com/git/git/blob/master/dir.c#L912:L912 if is_ignore && !entry.flags.contains(git_index::entry::Flags::SKIP_WORKTREE) { diff --git a/gitoxide-core/src/hours/mod.rs b/gitoxide-core/src/hours/mod.rs index fc5ec1f7174..94498410dc1 100644 --- a/gitoxide-core/src/hours/mod.rs +++ b/gitoxide-core/src/hours/mod.rs @@ -382,8 +382,8 @@ where for entry in results_by_hours.iter() { entry.write_to( total_hours, - file_stats.then(|| total_files), - line_stats.then(|| total_lines), + file_stats.then_some(total_files), + line_stats.then_some(total_lines), &mut out, )?; writeln!(out)?; @@ -395,7 +395,7 @@ where total_hours, total_hours / HOURS_PER_WORKDAY, total_commits, - is_shallow.then(|| " (shallow)").unwrap_or_default(), + is_shallow.then_some(" (shallow)").unwrap_or_default(), num_authors )?; if file_stats { diff --git a/gitoxide-core/src/index/checkout.rs b/gitoxide-core/src/index/checkout.rs index ff06c479fd0..516095205dc 100644 --- a/gitoxide-core/src/index/checkout.rs +++ b/gitoxide-core/src/index/checkout.rs @@ -124,7 +124,7 @@ pub fn checkout_exclusive( progress.done(format!( "Created {} {} files{} ({})", files_updated, - no_repo.then(|| "empty").unwrap_or_default(), + no_repo.then_some("empty").unwrap_or_default(), should_interrupt .load(Ordering::Relaxed) .then(|| { diff --git a/gitoxide-core/src/repository/clone.rs b/gitoxide-core/src/repository/clone.rs index dbe1009cee6..740a6e712e9 100644 --- a/gitoxide-core/src/repository/clone.rs +++ b/gitoxide-core/src/repository/clone.rs @@ -52,8 +52,11 @@ pub(crate) mod function { let mut prepare = git::clone::PrepareFetch::new( url, directory, - bare.then(|| git::create::Kind::Bare) - .unwrap_or(git::create::Kind::WithWorktree), + if bare { + git::create::Kind::Bare + } else { + git::create::Kind::WithWorktree + }, git::create::Options::default(), { let mut opts = git::open::Options::default().config_overrides(overrides); diff --git a/gitoxide-core/src/repository/config.rs b/gitoxide-core/src/repository/config.rs index 7eb58d13217..a6873406bd4 100644 --- a/gitoxide-core/src/repository/config.rs +++ b/gitoxide-core/src/repository/config.rs @@ -102,7 +102,7 @@ fn write_meta(meta: &git::config::file::Metadata, out: &mut impl std::io::Write) .then(|| format!(", include level {}", meta.level)) .unwrap_or_default(), (meta.trust != git::sec::Trust::Full) - .then(|| ", untrusted") + .then_some(", untrusted") .unwrap_or_default() ) } diff --git a/gitoxide-core/src/repository/exclude.rs b/gitoxide-core/src/repository/exclude.rs index b00c309a927..b4794f5a12d 100644 --- a/gitoxide-core/src/repository/exclude.rs +++ b/gitoxide-core/src/repository/exclude.rs @@ -51,7 +51,7 @@ pub fn query( let entry = cache.at_entry(path, is_dir, |oid, buf| repo.objects.find_blob(oid, buf))?; let match_ = entry .matching_exclude_pattern() - .and_then(|m| (show_ignore_patterns || !m.pattern.is_negative()).then(|| m)); + .and_then(|m| (show_ignore_patterns || !m.pattern.is_negative()).then_some(m)); match match_ { Some(m) => writeln!( out, diff --git a/gitoxide-core/src/repository/remote.rs b/gitoxide-core/src/repository/remote.rs index 15aff7c1a46..f913ad1d62d 100644 --- a/gitoxide-core/src/repository/remote.rs +++ b/gitoxide-core/src/repository/remote.rs @@ -156,9 +156,13 @@ mod refs_impl { match repo.try_find_reference(local)? { Some(tracking) => { let msg = match tracking.try_id() { - Some(id) => (id.as_ref() == target_id) - .then(|| "[up-to-date]") - .unwrap_or("[changed]"), + Some(id) => { + if id.as_ref() == target_id { + "[up-to-date]" + } else { + "[changed]" + } + } None => "[skipped]", }; writeln!(out, "{msg}") diff --git a/gitoxide-core/src/repository/tree.rs b/gitoxide-core/src/repository/tree.rs index 57618d73455..0436249a2b8 100644 --- a/gitoxide-core/src/repository/tree.rs +++ b/gitoxide-core/src/repository/tree.rs @@ -130,12 +130,12 @@ pub fn info( let tree = treeish_to_tree(treeish, &repo)?; - let mut delegate = entries::Traverse::new(extended.then(|| &repo), None); + let mut delegate = entries::Traverse::new(extended.then_some(&repo), None); tree.traverse().breadthfirst(&mut delegate)?; #[cfg(feature = "serde1")] { - delegate.stats.bytes = extended.then(|| delegate.stats.num_bytes); + delegate.stats.bytes = extended.then_some(delegate.stats.num_bytes); serde_json::to_writer_pretty(out, &delegate.stats)?; } @@ -157,7 +157,7 @@ pub fn entries( let tree = treeish_to_tree(treeish, &repo)?; if recursive { - let mut delegate = entries::Traverse::new(extended.then(|| &repo), Some(&mut out)); + let mut delegate = entries::Traverse::new(extended.then_some(&repo), Some(&mut out)); tree.traverse().breadthfirst(&mut delegate)?; } else { for entry in tree.iter() { diff --git a/src/plumbing/main.rs b/src/plumbing/main.rs index 282726cdf34..185e0bf7da9 100644 --- a/src/plumbing/main.rs +++ b/src/plumbing/main.rs @@ -389,7 +389,7 @@ pub fn main() -> Result<()> { let context = core::pack::create::Context { thread_limit, thin, - nondeterministic_thread_count: nondeterministic_count.then(|| counting_threads), + nondeterministic_thread_count: nondeterministic_count.then_some(counting_threads), pack_cache_size_in_bytes: pack_cache_size_mb.unwrap_or(0) * 1_000_000, object_cache_size_in_bytes: object_cache_size_mb.unwrap_or(0) * 1_000_000, statistics: if statistics { Some(format) } else { None }, @@ -638,7 +638,7 @@ pub fn main() -> Result<()> { progress, &should_interrupt, core::repository::verify::Context { - output_statistics: statistics.then(|| format), + output_statistics: statistics.then_some(format), algorithm, verify_mode: verify_mode(decode, re_encode), thread_limit, diff --git a/src/plumbing/progress.rs b/src/plumbing/progress.rs index 6f11c6b3663..a5f0c5ddcc1 100644 --- a/src/plumbing/progress.rs +++ b/src/plumbing/progress.rs @@ -1,3 +1,4 @@ +use std::borrow::Cow; use std::fmt::{Display, Formatter}; use crosstermion::crossterm::style::Stylize; @@ -55,7 +56,13 @@ impl Usage { NotApplicable { .. } => "❌", Planned { .. } => "🕒", NotPlanned { .. } => "🤔", - InModule { deviation, .. } => deviation.is_some().then(|| "👌️").unwrap_or("✅"), + InModule { deviation, .. } => { + if deviation.is_some() { + "👌️" + } else { + "✅" + } + } } } } @@ -69,7 +76,7 @@ struct Record { impl Tabled for Record { const LENGTH: usize = 3; - fn fields(&self) -> Vec { + fn fields(&self) -> Vec> { let mut tokens = self.config.split('.'); let mut buf = vec![{ let name = tokens.next().expect("present"); @@ -82,10 +89,14 @@ impl Tabled for Record { }]; buf.extend(tokens.map(ToOwned::to_owned)); - vec![self.usage.icon().into(), buf.join("."), self.usage.to_string()] + vec![ + Cow::Borrowed(self.usage.icon()), + buf.join(".").into(), + self.usage.to_string().into(), + ] } - fn headers() -> Vec { + fn headers() -> Vec> { vec![] } } diff --git a/tests/tools/src/lib.rs b/tests/tools/src/lib.rs index 35756a21516..f1ac72e1b9b 100644 --- a/tests/tools/src/lib.rs +++ b/tests/tools/src/lib.rs @@ -62,7 +62,7 @@ static EXCLUDE_LUT: Lazy>> = Lazy::new(|| let mut buf = Vec::with_capacity(512); let case = git_worktree::fs::Capabilities::probe(&work_tree) .ignore_case - .then(|| git_attributes::glob::pattern::Case::Fold) + .then_some(git_attributes::glob::pattern::Case::Fold) .unwrap_or_default(); let state = git_worktree::fs::cache::State::IgnoreStack(git_worktree::fs::cache::state::Ignore::new( Default::default(),