Merge branch 'develop'

This commit is contained in:
2022-10-06 12:38:32 +02:00
8 changed files with 63 additions and 78 deletions

65
Cargo.lock generated
View File

@@ -80,26 +80,24 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
version = "3.2.22" version = "4.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" checksum = "3b1a0a4208c6c483b952ad35c6eed505fc13b46f08f631b81e828084a9318d74"
dependencies = [ dependencies = [
"atty", "atty",
"bitflags", "bitflags",
"clap_derive", "clap_derive",
"clap_lex", "clap_lex",
"indexmap",
"once_cell", "once_cell",
"strsim", "strsim",
"termcolor", "termcolor",
"textwrap",
] ]
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "3.2.18" version = "4.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" checksum = "db342ce9fda24fb191e2ed4e102055a4d381c1086a06630174cd8da8d5d917ce"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error", "proc-macro-error",
@@ -110,9 +108,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_lex" name = "clap_lex"
version = "0.2.4" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
dependencies = [ dependencies = [
"os_str_bytes", "os_str_bytes",
] ]
@@ -140,13 +138,13 @@ dependencies = [
[[package]] [[package]]
name = "console" name = "console"
version = "0.15.1" version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89eab4d20ce20cea182308bca13088fecea9c05f6776cf287205d41a0ed3c847" checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c"
dependencies = [ dependencies = [
"encode_unicode", "encode_unicode",
"lazy_static",
"libc", "libc",
"once_cell",
"terminal_size", "terminal_size",
"unicode-width", "unicode-width",
"winapi", "winapi",
@@ -154,12 +152,11 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.11" version = "0.8.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"once_cell",
] ]
[[package]] [[package]]
@@ -329,7 +326,7 @@ dependencies = [
[[package]] [[package]]
name = "git-repo-manager" name = "git-repo-manager"
version = "0.7.8" version = "0.7.9"
dependencies = [ dependencies = [
"clap", "clap",
"comfy-table", "comfy-table",
@@ -460,9 +457,9 @@ checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754"
[[package]] [[package]]
name = "jobserver" name = "jobserver"
version = "0.1.24" version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@@ -475,9 +472,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.133" version = "0.2.134"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966" checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb"
[[package]] [[package]]
name = "libgit2-sys" name = "libgit2-sys"
@@ -595,9 +592,9 @@ dependencies = [
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.75" version = "0.9.76"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f" checksum = "5230151e44c0f05157effb743e8d517472843121cf9243e8b81393edb5acd9ce"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cc", "cc",
@@ -731,9 +728,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.43" version = "1.0.46"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@@ -963,9 +960,9 @@ dependencies = [
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.9.0" version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]] [[package]]
name = "socket2" name = "socket2"
@@ -1004,9 +1001,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.100" version = "1.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52205623b1b0f064a4e71182c3b18ae902267282930c6d5462c91b859668426e" checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -1042,26 +1039,20 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "textwrap"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16"
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.35" version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c53f98874615aea268107765aa1ed8f6116782501d18e53d08b471733bea6c85" checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.35" version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8b463991b4eab2d801e724172285ec4195c650e8ec79b149e6c2a8e6dd3f783" checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "git-repo-manager" name = "git-repo-manager"
version = "0.7.8" version = "0.7.9"
edition = "2021" edition = "2021"
authors = [ authors = [
@@ -54,11 +54,11 @@ version = "=0.15.0"
version = "=2.1.2" version = "=2.1.2"
[dependencies.clap] [dependencies.clap]
version = "=3.2.22" version = "=4.0.10"
features = ["derive", "cargo"] features = ["derive", "cargo"]
[dependencies.console] [dependencies.console]
version = "=0.15.1" version = "=0.15.2"
[dependencies.regex] [dependencies.regex]
version = "=1.6.0" version = "=1.6.0"

View File

@@ -1,5 +1,7 @@
set positional-arguments set positional-arguments
set shell := ["/bin/bash", "-c"]
static_target := "x86_64-unknown-linux-musl" static_target := "x86_64-unknown-linux-musl"
check: fmt-check lint test check: fmt-check lint test

View File

@@ -28,7 +28,7 @@ def get_temporary_directory(dir=None):
def grm(args, cwd=None, is_invalid=False): def grm(args, cwd=None, is_invalid=False):
cmd = subprocess.run([binary] + args, cwd=cwd, capture_output=True, text=True) cmd = subprocess.run([binary] + args, cwd=cwd, capture_output=True, text=True)
if not is_invalid: if not is_invalid:
assert "USAGE" not in cmd.stderr assert "usage" not in cmd.stderr.lower()
print(f"grmcmd: {args}") print(f"grmcmd: {args}")
print(f"stdout:\n{cmd.stdout}") print(f"stdout:\n{cmd.stdout}")
print(f"stderr:\n{cmd.stderr}") print(f"stderr:\n{cmd.stderr}")

View File

@@ -5,9 +5,9 @@ from helpers import *
def test_invalid_command(): def test_invalid_command():
cmd = grm(["whatever"], is_invalid=True) cmd = grm(["whatever"], is_invalid=True)
assert "USAGE" in cmd.stderr assert "usage" in cmd.stderr.lower()
def test_help(): def test_help():
cmd = grm(["--help"]) cmd = grm(["--help"])
assert "USAGE" in cmd.stdout assert "usage" in cmd.stdout.lower()

View File

@@ -1,4 +1,4 @@
use clap::{AppSettings, Parser}; use clap::Parser;
#[derive(Parser)] #[derive(Parser)]
#[clap( #[clap(
@@ -7,7 +7,6 @@ use clap::{AppSettings, Parser};
author = clap::crate_authors!("\n"), author = clap::crate_authors!("\n"),
about = clap::crate_description!(), about = clap::crate_description!(),
long_version = clap::crate_version!(), long_version = clap::crate_version!(),
global_setting(AppSettings::DeriveDisplayOrder),
propagate_version = true, propagate_version = true,
)] )]
pub struct Opts { pub struct Opts {
@@ -65,7 +64,7 @@ pub struct FindLocalArgs {
pub path: String, pub path: String,
#[clap( #[clap(
arg_enum, value_enum,
short, short,
long, long,
help = "Format to produce", help = "Format to produce",
@@ -85,7 +84,7 @@ pub struct FindConfigArgs {
pub config: String, pub config: String,
#[clap( #[clap(
arg_enum, value_enum,
short, short,
long, long,
help = "Format to produce", help = "Format to produce",
@@ -100,14 +99,14 @@ pub struct FindRemoteArgs {
#[clap(short, long, help = "Path to the configuration file")] #[clap(short, long, help = "Path to the configuration file")]
pub config: Option<String>, pub config: Option<String>,
#[clap(arg_enum, short, long, help = "Remote provider to use")] #[clap(value_enum, short, long, help = "Remote provider to use")]
pub provider: RemoteProvider, pub provider: RemoteProvider,
#[clap(short, long, help = "Name of the remote to use")] #[clap(short, long, help = "Name of the remote to use")]
pub remote_name: Option<String>, pub remote_name: Option<String>,
#[clap( #[clap(
multiple_occurrences = true, action = clap::ArgAction::Append,
name = "user", name = "user",
long, long,
help = "Users to get repositories from" help = "Users to get repositories from"
@@ -115,7 +114,7 @@ pub struct FindRemoteArgs {
pub users: Vec<String>, pub users: Vec<String>,
#[clap( #[clap(
multiple_occurrences = true, action = clap::ArgAction::Append,
name = "group", name = "group",
long, long,
help = "Groups to get repositories from" help = "Groups to get repositories from"
@@ -138,7 +137,7 @@ pub struct FindRemoteArgs {
pub root: String, pub root: String,
#[clap( #[clap(
arg_enum, value_enum,
short, short,
long, long,
help = "Format to produce", help = "Format to produce",
@@ -149,11 +148,10 @@ pub struct FindRemoteArgs {
#[clap( #[clap(
long, long,
help = "Use worktree setup for repositories", help = "Use worktree setup for repositories",
possible_values = &["true", "false"], value_parser = ["true", "false"],
default_value = "false", default_value = "false",
default_missing_value = "true", default_missing_value = "true",
min_values = 0, num_args = 0..=1,
max_values = 1,
)] )]
pub worktree: String, pub worktree: String,
@@ -174,12 +172,11 @@ pub struct Config {
#[clap( #[clap(
long, long,
value_parser = ["true", "false"],
help = "Check out the default worktree after clone", help = "Check out the default worktree after clone",
possible_values = &["true", "false"],
default_value = "true", default_value = "true",
default_missing_value = "true", default_missing_value = "true",
min_values = 0, num_args = 0..=1,
max_values = 1,
)] )]
pub init_worktree: String, pub init_worktree: String,
} }
@@ -189,14 +186,14 @@ pub type RemoteProvider = super::provider::RemoteProvider;
#[derive(Parser)] #[derive(Parser)]
#[clap()] #[clap()]
pub struct SyncRemoteArgs { 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, pub provider: RemoteProvider,
#[clap(short, long, help = "Name of the remote to use")] #[clap(short, long, help = "Name of the remote to use")]
pub remote_name: Option<String>, pub remote_name: Option<String>,
#[clap( #[clap(
multiple_occurrences = true, action = clap::ArgAction::Append,
name = "user", name = "user",
long, long,
help = "Users to get repositories from" help = "Users to get repositories from"
@@ -204,7 +201,7 @@ pub struct SyncRemoteArgs {
pub users: Vec<String>, pub users: Vec<String>,
#[clap( #[clap(
multiple_occurrences = true, action = clap::ArgAction::Append,
name = "group", name = "group",
long, long,
help = "Groups to get repositories from" help = "Groups to get repositories from"
@@ -229,11 +226,10 @@ pub struct SyncRemoteArgs {
#[clap( #[clap(
long, long,
help = "Use worktree setup for repositories", help = "Use worktree setup for repositories",
possible_values = &["true", "false"], value_parser = ["true", "false"],
default_value = "false", default_value = "false",
default_missing_value = "true", default_missing_value = "true",
min_values = 0, num_args = 0..=1,
max_values = 1,
)] )]
pub worktree: String, pub worktree: String,
@@ -243,11 +239,10 @@ pub struct SyncRemoteArgs {
#[clap( #[clap(
long, long,
help = "Check out the default worktree after clone", help = "Check out the default worktree after clone",
possible_values = &["true", "false"], value_parser = ["true", "false"],
default_value = "true", default_value = "true",
default_missing_value = "true", default_missing_value = "true",
min_values = 0, num_args = 0..=1,
max_values = 1,
)] )]
pub init_worktree: String, pub init_worktree: String,
} }
@@ -259,7 +254,7 @@ pub struct OptionalConfig {
pub config: Option<String>, pub config: Option<String>,
} }
#[derive(clap::ArgEnum, Clone)] #[derive(clap::ValueEnum, Clone)]
pub enum ConfigFormat { pub enum ConfigFormat {
Yaml, Yaml,
Toml, Toml,
@@ -299,7 +294,7 @@ pub struct WorktreeAddArgs {
#[clap(short = 't', long = "track", help = "Remote branch to track")] #[clap(short = 't', long = "track", help = "Remote branch to track")]
pub track: Option<String>, pub track: Option<String>,
#[clap(long = "--no-track", help = "Disable tracking")] #[clap(long = "no-track", help = "Disable tracking")]
pub no_track: bool, pub no_track: bool,
} }
#[derive(Parser)] #[derive(Parser)]
@@ -328,22 +323,19 @@ pub struct WorktreeFetchArgs {}
#[derive(Parser)] #[derive(Parser)]
pub struct WorktreePullArgs { 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, 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, pub stash: bool,
} }
#[derive(Parser)] #[derive(Parser)]
pub struct WorktreeRebaseArgs { pub struct WorktreeRebaseArgs {
#[clap(long = "--pull", help = "Perform a pull before rebasing")] #[clap(long = "pull", help = "Perform a pull before rebasing")]
pub pull: bool, 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, pub rebase: bool,
#[clap( #[clap(long = "stash", help = "Stash & unstash changes before & after rebase")]
long = "--stash",
help = "Stash & unstash changes before & after rebase"
)]
pub stash: bool, pub stash: bool,
} }

View File

@@ -16,7 +16,7 @@ use std::collections::HashMap;
const DEFAULT_REMOTE_NAME: &str = "origin"; const DEFAULT_REMOTE_NAME: &str = "origin";
#[derive(Debug, Deserialize, Serialize, clap::ArgEnum, Clone)] #[derive(Debug, Deserialize, Serialize, clap::ValueEnum, Clone)]
pub enum RemoteProvider { pub enum RemoteProvider {
#[serde(alias = "github", alias = "GitHub")] #[serde(alias = "github", alias = "GitHub")]
Github, Github,

View File

@@ -372,7 +372,7 @@ impl<'a> Worktree<'a, WithRemoteTrackingBranch<'a>> {
// TECHDEBT // TECHDEBT
// We must not call this with `Some()` without a valid target. // We must not call this with `Some()` without a valid target.
// I'm sure this can be improved, just not sure how. // I'm sure this can be improved, just not sure how.
&*self.extra.target_commit.unwrap(), &self.extra.target_commit.unwrap(),
)? )?
}; };