Skip to content

Commit

Permalink
bump min git version to 2.43 due to bug in set-branch and set-url (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pistonight authored Dec 2, 2023
1 parent 29b6b59 commit 66e76cb
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "magoo"
version = "0.1.2"
version = "0.1.3"
edition = "2021"
description = "A wrapper for git submodule that simplifies the workflows"
repository = "https://github.com/Pistonite/magoo"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ magoo status --git

Unsupported versions might work as well, ![magoo](https://raw.githubusercontent.com/Pistonite/magoo/main/magoo.webp) just doesn't know.

**git <=2.42.0 doesn't work due to a bug in set-branch and set-url commands**


### Add a submodule
```bash
Expand Down
2 changes: 2 additions & 0 deletions README.txtpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ TXTPP#tag MAGOO
TXTPP#include magoo.txt
Unsupported versions might work as well, MAGOO just doesn't know.

**git <=2.42.0 doesn't work due to a bug in set-branch and set-url commands**


### Add a submodule
```bash
Expand Down
8 changes: 6 additions & 2 deletions src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::print::{self, println_info, println_verbose, println_warn};
/// The semver notation of the officially supported git versions
///
/// The version is not checked at run time, since unsupported versions might work fine.
pub const SUPPORTED_GIT_VERSIONS: &str = ">=2.35.0";
pub const SUPPORTED_GIT_VERSIONS: &str = ">=2.43.0";

/// Context for running git commands
pub struct GitContext {
Expand Down Expand Up @@ -402,6 +402,8 @@ impl GitContext {
}

/// Runs `git submodule set-branch`. Path should be from top level
///
/// Note: Pre git 2.43, there's a bug treating the argument as name instead of path.
pub fn submodule_set_branch(&self, path: &str, branch: Option<&str>) -> Result<(), GitError> {
let top_level_dir = self.top_level_dir()?.to_cmd_arg();
let mut args = vec!["-C", &top_level_dir, "submodule", "set-branch"];
Expand All @@ -420,7 +422,9 @@ impl GitContext {
Ok(())
}

/// Runs `git submodule set-url`. Path should be from top level
/// Runs `git submodule set-url`.
///
/// Note: Pre git 2.43, there's a bug treating the argument as name instead of path.
pub fn submodule_set_url(&self, path: &str, url: &str) -> Result<(), GitError> {
let top_level_dir = self.top_level_dir()?.to_cmd_arg();
self.run_git_command(
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub struct Magoo {
#[clap(subcommand)]
pub subcmd: Command,
/// Set the working directory of commands. Useful if not running inside a git repository.
#[cfg_attr(feature = "cli", clap(long, default_value(".")))]
#[cfg_attr(feature = "cli", clap(long, short('C'), default_value(".")))]
pub dir: String,
}

Expand Down

0 comments on commit 66e76cb

Please sign in to comment.