From 6e876aaefc3ef6a174eda009e897f65840512aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Thu, 6 Oct 2022 11:36:47 +0200 Subject: [PATCH 01/11] dependencies: Update clap to 4.0.10 --- Cargo.lock | 32 ++++++++++++-------------------- Cargo.toml | 2 +- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f768f9d..f6aeffb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,26 +80,24 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "3.2.22" +version = "4.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" +checksum = "3b1a0a4208c6c483b952ad35c6eed505fc13b46f08f631b81e828084a9318d74" dependencies = [ "atty", "bitflags", "clap_derive", "clap_lex", - "indexmap", "once_cell", "strsim", "termcolor", - "textwrap", ] [[package]] name = "clap_derive" -version = "3.2.18" +version = "4.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +checksum = "db342ce9fda24fb191e2ed4e102055a4d381c1086a06630174cd8da8d5d917ce" dependencies = [ "heck", "proc-macro-error", @@ -110,9 +108,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" dependencies = [ "os_str_bytes", ] @@ -475,9 +473,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.133" +version = "0.2.134" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966" +checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb" [[package]] name = "libgit2-sys" @@ -731,9 +729,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.43" +version = "1.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" +checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" dependencies = [ "unicode-ident", ] @@ -1004,9 +1002,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.100" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52205623b1b0f064a4e71182c3b18ae902267282930c6d5462c91b859668426e" +checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2" dependencies = [ "proc-macro2", "quote", @@ -1042,12 +1040,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "textwrap" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" - [[package]] name = "thiserror" version = "1.0.35" diff --git a/Cargo.toml b/Cargo.toml index 89453f3..5354072 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,7 +54,7 @@ version = "=0.15.0" version = "=2.1.2" [dependencies.clap] -version = "=3.2.22" +version = "=4.0.10" features = ["derive", "cargo"] [dependencies.console] From bd79602d3a040999caae7e857dcee891085dbb1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Thu, 6 Oct 2022 11:36:47 +0200 Subject: [PATCH 02/11] dependencies: Update console to 0.15.2 --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f6aeffb..ebd0c88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -138,13 +138,13 @@ dependencies = [ [[package]] name = "console" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89eab4d20ce20cea182308bca13088fecea9c05f6776cf287205d41a0ed3c847" +checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c" dependencies = [ "encode_unicode", + "lazy_static", "libc", - "once_cell", "terminal_size", "unicode-width", "winapi", diff --git a/Cargo.toml b/Cargo.toml index 5354072..4c95105 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ version = "=4.0.10" features = ["derive", "cargo"] [dependencies.console] -version = "=0.15.1" +version = "=0.15.2" [dependencies.regex] version = "=1.6.0" From e65c744f9cefa5516c5245778293b88c41952fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Thu, 6 Oct 2022 11:36:48 +0200 Subject: [PATCH 03/11] Cargo.lock: Updating jobserver v0.1.24 -> v0.1.25 --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ebd0c88..535c03d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -458,9 +458,9 @@ checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" [[package]] name = "jobserver" -version = "0.1.24" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" dependencies = [ "libc", ] From 7db3596302a151b76888da241096c454adad0324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Thu, 6 Oct 2022 11:36:49 +0200 Subject: [PATCH 04/11] Cargo.lock: Updating smallvec v1.9.0 -> v1.10.0 --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 535c03d..2c8c1e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -961,9 +961,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "socket2" From 87d5b7ad8502c430590377e641cce38be190f842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Thu, 6 Oct 2022 11:36:50 +0200 Subject: [PATCH 05/11] Cargo.lock: Updating crossbeam-utils v0.8.11 -> v0.8.12 --- Cargo.lock | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2c8c1e9..87694cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -152,12 +152,11 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" +checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac" dependencies = [ "cfg-if", - "once_cell", ] [[package]] From 0fa2a65c814157d500000ccec83545e38993ba6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Thu, 6 Oct 2022 11:36:52 +0200 Subject: [PATCH 06/11] Cargo.lock: Updating openssl-sys v0.9.75 -> v0.9.76 --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 87694cb..1f05b4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -592,9 +592,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.75" +version = "0.9.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f" +checksum = "5230151e44c0f05157effb743e8d517472843121cf9243e8b81393edb5acd9ce" dependencies = [ "autocfg", "cc", From 918b63047b8e03f54e94d8d59758711efa072652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Thu, 6 Oct 2022 11:36:53 +0200 Subject: [PATCH 07/11] Cargo.lock: Updating thiserror v1.0.35 -> v1.0.37 --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1f05b4c..3a0b895 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1041,18 +1041,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.35" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c53f98874615aea268107765aa1ed8f6116782501d18e53d08b471733bea6c85" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.35" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8b463991b4eab2d801e724172285ec4195c650e8ec79b149e6c2a8e6dd3f783" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ "proc-macro2", "quote", From 58800665311d49cffd47af375577610b6eb7ac82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Thu, 6 Oct 2022 11:52:59 +0200 Subject: [PATCH 08/11] cli: Update code for clap v4 --- e2e_tests/helpers.py | 2 +- e2e_tests/test_basic.py | 4 +-- src/grm/cmd.rs | 58 ++++++++++++++++++----------------------- src/provider/mod.rs | 2 +- 4 files changed, 29 insertions(+), 37 deletions(-) diff --git a/e2e_tests/helpers.py b/e2e_tests/helpers.py index 8718ca5..b9567e6 100644 --- a/e2e_tests/helpers.py +++ b/e2e_tests/helpers.py @@ -28,7 +28,7 @@ def get_temporary_directory(dir=None): def grm(args, cwd=None, is_invalid=False): cmd = subprocess.run([binary] + args, cwd=cwd, capture_output=True, text=True) if not is_invalid: - assert "USAGE" not in cmd.stderr + assert "usage" not in cmd.stderr.lower() print(f"grmcmd: {args}") print(f"stdout:\n{cmd.stdout}") print(f"stderr:\n{cmd.stderr}") diff --git a/e2e_tests/test_basic.py b/e2e_tests/test_basic.py index fc2ae9c..6ea5172 100644 --- a/e2e_tests/test_basic.py +++ b/e2e_tests/test_basic.py @@ -5,9 +5,9 @@ from helpers import * def test_invalid_command(): cmd = grm(["whatever"], is_invalid=True) - assert "USAGE" in cmd.stderr + assert "usage" in cmd.stderr.lower() def test_help(): cmd = grm(["--help"]) - assert "USAGE" in cmd.stdout + assert "usage" in cmd.stdout.lower() diff --git a/src/grm/cmd.rs b/src/grm/cmd.rs index 178f28e..4b0fd1e 100644 --- a/src/grm/cmd.rs +++ b/src/grm/cmd.rs @@ -1,4 +1,4 @@ -use clap::{AppSettings, Parser}; +use clap::Parser; #[derive(Parser)] #[clap( @@ -7,7 +7,6 @@ use clap::{AppSettings, Parser}; author = clap::crate_authors!("\n"), about = clap::crate_description!(), long_version = clap::crate_version!(), - global_setting(AppSettings::DeriveDisplayOrder), propagate_version = true, )] pub struct Opts { @@ -65,7 +64,7 @@ pub struct FindLocalArgs { pub path: String, #[clap( - arg_enum, + value_enum, short, long, help = "Format to produce", @@ -85,7 +84,7 @@ pub struct FindConfigArgs { pub config: String, #[clap( - arg_enum, + value_enum, short, long, help = "Format to produce", @@ -100,14 +99,14 @@ pub struct FindRemoteArgs { #[clap(short, long, help = "Path to the configuration file")] pub config: Option, - #[clap(arg_enum, short, long, help = "Remote provider to use")] + #[clap(value_enum, short, long, help = "Remote provider to use")] pub provider: RemoteProvider, #[clap(short, long, help = "Name of the remote to use")] pub remote_name: Option, #[clap( - multiple_occurrences = true, + action = clap::ArgAction::Append, name = "user", long, help = "Users to get repositories from" @@ -115,7 +114,7 @@ pub struct FindRemoteArgs { pub users: Vec, #[clap( - multiple_occurrences = true, + action = clap::ArgAction::Append, name = "group", long, help = "Groups to get repositories from" @@ -138,7 +137,7 @@ pub struct FindRemoteArgs { pub root: String, #[clap( - arg_enum, + value_enum, short, long, help = "Format to produce", @@ -149,11 +148,10 @@ pub struct FindRemoteArgs { #[clap( long, help = "Use worktree setup for repositories", - possible_values = &["true", "false"], + value_parser = ["true", "false"], default_value = "false", default_missing_value = "true", - min_values = 0, - max_values = 1, + num_args = 0..=1, )] pub worktree: String, @@ -174,12 +172,11 @@ pub struct Config { #[clap( long, + value_parser = ["true", "false"], help = "Check out the default worktree after clone", - possible_values = &["true", "false"], default_value = "true", default_missing_value = "true", - min_values = 0, - max_values = 1, + num_args = 0..=1, )] pub init_worktree: String, } @@ -189,14 +186,14 @@ pub type RemoteProvider = super::provider::RemoteProvider; #[derive(Parser)] #[clap()] pub struct SyncRemoteArgs { - #[clap(arg_enum, short, long, help = "Remote provider to use")] + #[clap(value_enum, short, long, help = "Remote provider to use")] pub provider: RemoteProvider, #[clap(short, long, help = "Name of the remote to use")] pub remote_name: Option, #[clap( - multiple_occurrences = true, + action = clap::ArgAction::Append, name = "user", long, help = "Users to get repositories from" @@ -204,7 +201,7 @@ pub struct SyncRemoteArgs { pub users: Vec, #[clap( - multiple_occurrences = true, + action = clap::ArgAction::Append, name = "group", long, help = "Groups to get repositories from" @@ -229,11 +226,10 @@ pub struct SyncRemoteArgs { #[clap( long, help = "Use worktree setup for repositories", - possible_values = &["true", "false"], + value_parser = ["true", "false"], default_value = "false", default_missing_value = "true", - min_values = 0, - max_values = 1, + num_args = 0..=1, )] pub worktree: String, @@ -243,11 +239,10 @@ pub struct SyncRemoteArgs { #[clap( long, help = "Check out the default worktree after clone", - possible_values = &["true", "false"], + value_parser = ["true", "false"], default_value = "true", default_missing_value = "true", - min_values = 0, - max_values = 1, + num_args = 0..=1, )] pub init_worktree: String, } @@ -259,7 +254,7 @@ pub struct OptionalConfig { pub config: Option, } -#[derive(clap::ArgEnum, Clone)] +#[derive(clap::ValueEnum, Clone)] pub enum ConfigFormat { Yaml, Toml, @@ -299,7 +294,7 @@ pub struct WorktreeAddArgs { #[clap(short = 't', long = "track", help = "Remote branch to track")] pub track: Option, - #[clap(long = "--no-track", help = "Disable tracking")] + #[clap(long = "no-track", help = "Disable tracking")] pub no_track: bool, } #[derive(Parser)] @@ -328,22 +323,19 @@ pub struct WorktreeFetchArgs {} #[derive(Parser)] pub struct WorktreePullArgs { - #[clap(long = "--rebase", help = "Perform a rebase instead of a fast-forward")] + #[clap(long = "rebase", help = "Perform a rebase instead of a fast-forward")] pub rebase: bool, - #[clap(long = "--stash", help = "Stash & unstash changes before & after pull")] + #[clap(long = "stash", help = "Stash & unstash changes before & after pull")] pub stash: bool, } #[derive(Parser)] pub struct WorktreeRebaseArgs { - #[clap(long = "--pull", help = "Perform a pull before rebasing")] + #[clap(long = "pull", help = "Perform a pull before rebasing")] pub pull: bool, - #[clap(long = "--rebase", help = "Perform a rebase when doing a pull")] + #[clap(long = "rebase", help = "Perform a rebase when doing a pull")] pub rebase: bool, - #[clap( - long = "--stash", - help = "Stash & unstash changes before & after rebase" - )] + #[clap(long = "stash", help = "Stash & unstash changes before & after rebase")] pub stash: bool, } diff --git a/src/provider/mod.rs b/src/provider/mod.rs index c96557f..87a43bb 100644 --- a/src/provider/mod.rs +++ b/src/provider/mod.rs @@ -16,7 +16,7 @@ use std::collections::HashMap; const DEFAULT_REMOTE_NAME: &str = "origin"; -#[derive(Debug, Deserialize, Serialize, clap::ArgEnum, Clone)] +#[derive(Debug, Deserialize, Serialize, clap::ValueEnum, Clone)] pub enum RemoteProvider { #[serde(alias = "github", alias = "GitHub")] Github, From c6a27525fd867bb2cf50c4276f5b666a4c2f0977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Thu, 6 Oct 2022 12:20:30 +0200 Subject: [PATCH 09/11] Remove unnecessary deref --- src/worktree.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/worktree.rs b/src/worktree.rs index b7845cc..f5396ff 100644 --- a/src/worktree.rs +++ b/src/worktree.rs @@ -372,7 +372,7 @@ impl<'a> Worktree<'a, WithRemoteTrackingBranch<'a>> { // TECHDEBT // We must not call this with `Some()` without a valid target. // I'm sure this can be improved, just not sure how. - &*self.extra.target_commit.unwrap(), + &self.extra.target_commit.unwrap(), )? }; From d5bbbe61710461e297874279ea5e3d381c16cff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Thu, 6 Oct 2022 12:28:20 +0200 Subject: [PATCH 10/11] just: Use bash explicitly --- Justfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Justfile b/Justfile index 93dd82a..05140c0 100644 --- a/Justfile +++ b/Justfile @@ -1,5 +1,7 @@ set positional-arguments +set shell := ["/bin/bash", "-c"] + static_target := "x86_64-unknown-linux-musl" check: fmt-check lint test From 8a04db8130e3bfce766a007e4965c4f5ae60ab30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Thu, 6 Oct 2022 12:38:32 +0200 Subject: [PATCH 11/11] Release v0.7.9 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3a0b895..4478d12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -326,7 +326,7 @@ dependencies = [ [[package]] name = "git-repo-manager" -version = "0.7.8" +version = "0.7.9" dependencies = [ "clap", "comfy-table", diff --git a/Cargo.toml b/Cargo.toml index 4c95105..5abea18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "git-repo-manager" -version = "0.7.8" +version = "0.7.9" edition = "2021" authors = [