diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bb7929d..0dbc649 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,11 +57,13 @@ jobs: strip target/release/git-current-branch strip target/release/git-repo-title strip target/release/git-repo-url + strip target/release/git-sync tar -czvf ${{ matrix.asset_name }} -C target/release \ git-current-branch \ git-default-branch \ git-repo-title \ - git-repo-url + git-repo-url \ + git-sync - name: Build (windows) if: matrix.os == 'windows-latest' diff --git a/Cargo.lock b/Cargo.lock index 4bc825f..7640890 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aho-corasick" @@ -11,6 +11,56 @@ dependencies = [ "memchr", ] +[[package]] +name = "anstream" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +dependencies = [ + "anstyle", + "once_cell", + "windows-sys", +] + [[package]] name = "bitflags" version = "2.4.0" @@ -28,40 +78,57 @@ dependencies = [ ] [[package]] -name = "env_logger" -version = "0.10.1" +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "env_filter" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" dependencies = [ - "humantime", - "is-terminal", "log", "regex", - "termcolor", ] [[package]] -name = "errno" -version = "0.3.8" +name = "env_logger" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f" dependencies = [ - "libc", - "windows-sys", + "anstream", + "anstyle", + "env_filter", + "jiff", + "log", ] [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] [[package]] name = "git-current-branch" -version = "0.1.1" +version = "0.1.2" dependencies = [ "env_logger", "git-utils", @@ -71,7 +138,7 @@ dependencies = [ [[package]] name = "git-default-branch" -version = "0.1.1" +version = "0.1.2" dependencies = [ "env_logger", "git-utils", @@ -81,7 +148,7 @@ dependencies = [ [[package]] name = "git-repo-title" -version = "0.1.1" +version = "0.1.2" dependencies = [ "env_logger", "git-utils", @@ -91,7 +158,7 @@ dependencies = [ [[package]] name = "git-repo-url" -version = "0.1.1" +version = "0.1.2" dependencies = [ "env_logger", "git-utils", @@ -100,8 +167,8 @@ dependencies = [ ] [[package]] -name = "git-up" -version = "0.1.1" +name = "git-sync" +version = "0.1.2" dependencies = [ "env_logger", "git-utils", @@ -121,9 +188,9 @@ dependencies = [ [[package]] name = "git2" -version = "0.19.0" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724" +checksum = "2deb07a133b1520dc1a5690e9bd08950108873d7ed5de38dcc74d3b5ebffa110" dependencies = [ "bitflags", "libc", @@ -135,36 +202,172 @@ dependencies = [ ] [[package]] -name = "hermit-abi" -version = "0.3.3" +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e8338228bdc8ab83303f16b797e177953730f601a96c25d10cb3ab0daa0cb7" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85fb8799753b75aee8d2a21d7c14d9f38921b54b3dbda10f5a3c7a7b82dba5e2" + +[[package]] +name = "icu_provider" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] [[package]] -name = "humantime" -version = "2.1.0" +name = "icu_provider_macros" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "idna" -version = "0.4.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", ] [[package]] -name = "is-terminal" -version = "0.4.10" +name = "idna_adapter" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" dependencies = [ - "hermit-abi", - "rustix", - "windows-sys", + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + +[[package]] +name = "jiff" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f02000660d30638906021176af16b17498bd0d12813dbfe7b276d8bc7f3c0806" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde", +] + +[[package]] +name = "jiff-static" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c30758ddd7188629c6713fc45d1188af4f44c90582311d0c8d8c9907f60c48" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -184,9 +387,9 @@ checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "libgit2-sys" -version = "0.17.0+1.8.1" +version = "0.18.1+1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224" +checksum = "e1dcb20f84ffcdd825c7a311ae347cce604a6f084a767dec4a4929829645290e" dependencies = [ "cc", "libc", @@ -223,16 +426,16 @@ dependencies = [ ] [[package]] -name = "linux-raw-sys" -version = "0.4.12" +name = "litemap" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856" [[package]] name = "log" -version = "0.4.20" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "memchr" @@ -240,6 +443,12 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + [[package]] name = "openssl-probe" version = "0.1.5" @@ -260,9 +469,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pkg-config" @@ -270,6 +479,39 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[package]] +name = "portable-atomic" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "proc-macro2" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + [[package]] name = "regex" version = "1.10.2" @@ -300,123 +542,129 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] -name = "rustix" -version = "0.38.28" +name = "serde" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ - "bitflags", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", + "serde_derive", ] [[package]] -name = "termcolor" -version = "1.4.0" +name = "serde_derive" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ - "winapi-util", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "tinyvec" -version = "1.6.0" +name = "smallvec" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" [[package]] -name = "tinyvec_macros" -version = "0.1.1" +name = "stable_deref_trait" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] -name = "unicode-bidi" -version = "0.3.13" +name = "syn" +version = "2.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] [[package]] -name = "unicode-normalization" -version = "0.1.22" +name = "synstructure" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ - "tinyvec", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "url" -version = "2.4.1" +name = "tinystr" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", + "displaydoc", + "zerovec", ] [[package]] -name = "vcpkg" -version = "0.2.15" +name = "unicode-ident" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] -name = "winapi" -version = "0.3.9" +name = "url" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "form_urlencoded", + "idna", + "percent-encoding", ] [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "utf16_iter" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" [[package]] -name = "winapi-util" -version = "0.1.6" +name = "utf8_iter" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "vcpkg" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", + "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", @@ -425,42 +673,127 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index 5b606eb..b21b402 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,18 +5,18 @@ members = [ "git-default-branch", "git-repo-title", "git-repo-url", - "git-up", + "git-sync", ] resolver = "2" [workspace.package] -version = "0.1.1" +version = "0.1.2" authors = ["Geoff Johnson "] edition = "2021" [workspace.dependencies] -env_logger = "0.10" -git2 = "0.19" +env_logger = "0.11.8" +git2 = "0.20" log = "0.4" [profile.release] diff --git a/README.md b/README.md index b2aad5e..524ff33 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,10 @@ Prints the repository, eg. `geoffjay/git-utils`. Prints the full repository url, eg. `git@github.com:geoffjay/git-utils`. +#### `git-sync` + +Synchronizes the local with remote and cleans up branches that have been removed. + ### Installation #### macOS @@ -57,9 +61,9 @@ want them to go. Adjust the command for your environment if this is not what's desired. ```shell -curl -LO https://github.com/geoffjay/git-utils/releases/latest/download/git-utils-v0.1.1-darwin-x86_64.tar.gz -tar -xf git-utils-v0.1.1-darwin-x86_64.tar.gz -C ~/.local/bin -rm git-utils-v0.1.1-darwin-x86_64.tar.gz +curl -LO https://github.com/geoffjay/git-utils/releases/latest/download/git-utils-v0.1.2-darwin-x86_64.tar.gz +tar -xf git-utils-v0.1.2-darwin-x86_64.tar.gz -C ~/.local/bin +rm git-utils-v0.1.2-darwin-x86_64.tar.gz ``` #### Linux @@ -71,9 +75,9 @@ want them to go. Adjust the command for your environment if this is not what's desired. ```shell -curl -LO https://github.com/geoffjay/git-utils/releases/latest/download/git-utils-v0.1.1-linux-x86_64.tar.gz -tar -xf git-utils-v0.1.1-darwin-x86_64.tar.gz -C ~/.local/bin -rm git-utils-v0.1.1-linux-x86_64.tar.gz +curl -LO https://github.com/geoffjay/git-utils/releases/latest/download/git-utils-v0.1.2-linux-x86_64.tar.gz +tar -xf git-utils-v0.1.2-darwin-x86_64.tar.gz -C ~/.local/bin +rm git-utils-v0.1.2-linux-x86_64.tar.gz ``` #### Windows diff --git a/git-up/Cargo.toml b/git-sync/Cargo.toml similarity index 92% rename from git-up/Cargo.toml rename to git-sync/Cargo.toml index 332a151..565e74e 100644 --- a/git-up/Cargo.toml +++ b/git-sync/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "git-up" +name = "git-sync" version.workspace = true authors.workspace = true edition.workspace = true diff --git a/git-up/src/main.rs b/git-sync/src/main.rs similarity index 73% rename from git-up/src/main.rs rename to git-sync/src/main.rs index 523a411..63fb4e4 100644 --- a/git-up/src/main.rs +++ b/git-sync/src/main.rs @@ -3,8 +3,8 @@ use log::{debug, error}; use git_utils::{log_prepare, Command}; fn main() { - log_prepare(module_path!(), "git-up"); - let command = Command::new("git-up".to_string()); + log_prepare(module_path!(), "git-sync"); + let command = Command::new("git-sync".to_string()); match command.sync() { Ok(_) => (), @@ -15,4 +15,4 @@ fn main() { } debug!("git up completed successfully"); -} \ No newline at end of file +} diff --git a/git-utils/src/lib.rs b/git-utils/src/lib.rs index ba5b239..28305b4 100644 --- a/git-utils/src/lib.rs +++ b/git-utils/src/lib.rs @@ -149,8 +149,8 @@ impl Command { /// - remove any branches that contain ": gone]" from `git branch -vv` /// - if the current branch is not the default branch, `git fetch origin default_branch:default_branch` pub fn sync(self: Command) -> Result<(), Error> { - // let default_branch = self.clone().default_branch()?; - // let current_branch = self.clone().current_branch()?; + let default_branch = self.clone().default_branch()?; + let current_branch = self.clone().current_branch()?; let config = &self.repo.config().unwrap(); // fetch all branches @@ -171,15 +171,18 @@ impl Command { callbacks.credentials(f); log::debug!("connecting to remote"); - let mut fetch_options = git2::FetchOptions::new(); - fetch_options.remote_callbacks(callbacks) + fetch_options + .remote_callbacks(callbacks) .proxy_options(proxy_options); log::debug!("fetching from remote"); - - let fetch_result = remote.fetch(&["--no-tags", "--all", "-p"], Some(&mut fetch_options), None)?; - + // equivalent to: x-fetch-all = fetch --no-tags --all -p + let fetch_result = remote.fetch( + &["--no-tags", "--all", "-p"], + Some(&mut fetch_options), + None, + )?; log::debug!("fetch result: {:?}", fetch_result); // Perform fast-forward merge @@ -188,8 +191,8 @@ impl Command { log::debug!("upstream branch: {}", upstream_branch); + // equivalent to: x-merge-ff = merge --ff-only || true if let Ok(upstream_oid) = self.repo.refname_to_id(&upstream_branch) { - // let upstream_commit = self.repo.find_commit(upstream_oid)?; let annotated_commit = self.repo.find_annotated_commit(upstream_oid)?; // Attempt fast-forward merge match self.repo.merge_analysis(&[&annotated_commit]) { @@ -197,7 +200,8 @@ impl Command { if analysis.is_fast_forward() { let mut reference = self.repo.find_reference("HEAD")?; reference.set_target(upstream_oid, "Fast-forward merge")?; - self.repo.checkout_head(Some(git2::build::CheckoutBuilder::new().force()))?; + self.repo + .checkout_head(Some(git2::build::CheckoutBuilder::new().force()))?; } // If not fast-forward, do nothing (equivalent to `|| true`) } @@ -205,9 +209,65 @@ impl Command { } } + // Remove branches that contain ": gone]" + // equivalent to: x-branch-tidy = "!f() { git branch -vv | grep ': gone]' | awk '{print $1}' | xargs -n 1 git branch -D; }; f" + log::debug!("cleaning up branches"); + let branches = self.repo.branches(Some(git2::BranchType::Local))?; + for branch_result in branches { + let (mut branch, _) = branch_result?; + let branch_name = branch.name()?.unwrap_or("").to_string(); + + // Skip the current branch + if branch_name == current_branch { + continue; + } + + let upstream = match branch.upstream() { + Ok(_) => true, + Err(_) => false, + }; + + // If upstream doesn't exist (which means it's "gone"), delete the branch + if !upstream { + log::debug!("removing branch {}", branch_name); + branch.delete()?; + } + } + Ok(()) }); + // If we successfully performed the first part, check if we need to fetch the default branch + // equivalent to: x-fetch-branch = !"f() { git fetch origin $1:$1; }; f" + // equivalent to: if [ "$current" != "$default" ]; then git x-fetch-branch $default; fi; + if result.is_ok() && current_branch != default_branch { + log::debug!("fetching default branch: {}", default_branch); + + // Create a new authentication call to fetch the default branch + let default_branch_result = with_authentication(url, config, |f| { + let mut callbacks = RemoteCallbacks::new(); + callbacks.credentials(f); + + let mut proxy_options = ProxyOptions::new(); + proxy_options.auto(); + + let mut fetch_options = git2::FetchOptions::new(); + fetch_options + .remote_callbacks(callbacks) + .proxy_options(proxy_options); + + let refspec = format!("{}:{}", default_branch, default_branch); + log::debug!("refspec: {}", refspec); + + let fetch_result = remote.fetch(&[&refspec], Some(&mut fetch_options), None)?; + Ok(fetch_result) + }); + + if let Err(CommandError::GitError(e)) = default_branch_result { + return Err(e); + } + } + match result { Ok(_) => Ok(()), Err(CommandError::GitError(e)) => Err(e),