Compare commits
10 Commits
v0.7.8
...
d5bbbe6171
| Author | SHA1 | Date | |
|---|---|---|---|
| d5bbbe6171 | |||
| c6a27525fd | |||
| 5880066531 | |||
| 918b63047b | |||
| 0fa2a65c81 | |||
| 87d5b7ad85 | |||
| 7db3596302 | |||
| e65c744f9c | |||
| bd79602d3a | |||
| 6e876aaefc |
63
Cargo.lock
generated
63
Cargo.lock
generated
@@ -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",
|
||||
]
|
||||
@@ -140,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",
|
||||
@@ -154,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]]
|
||||
@@ -460,9 +457,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",
|
||||
]
|
||||
@@ -475,9 +472,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"
|
||||
@@ -595,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",
|
||||
@@ -731,9 +728,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",
|
||||
]
|
||||
@@ -963,9 +960,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"
|
||||
@@ -1004,9 +1001,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,26 +1039,20 @@ 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"
|
||||
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",
|
||||
|
||||
@@ -54,11 +54,11 @@ version = "=0.15.0"
|
||||
version = "=2.1.2"
|
||||
|
||||
[dependencies.clap]
|
||||
version = "=3.2.22"
|
||||
version = "=4.0.10"
|
||||
features = ["derive", "cargo"]
|
||||
|
||||
[dependencies.console]
|
||||
version = "=0.15.1"
|
||||
version = "=0.15.2"
|
||||
|
||||
[dependencies.regex]
|
||||
version = "=1.6.0"
|
||||
|
||||
2
Justfile
2
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
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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<String>,
|
||||
|
||||
#[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<String>,
|
||||
|
||||
#[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<String>,
|
||||
|
||||
#[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<String>,
|
||||
|
||||
#[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<String>,
|
||||
|
||||
#[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<String>,
|
||||
}
|
||||
|
||||
#[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<String>,
|
||||
|
||||
#[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,
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(),
|
||||
)?
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user