-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove footgun with
add.branch_replacements
(#92)
If you defined `add.branch_replacements` in your `config.toml`, but the result of applying the replacements included a `/`, `git-prole` would naively use that as the basename of a directory, causing problems (like the parent directory not existing). Now, the last component of the result is used, to match the behavior when `add.branch_replacements` is not set. Fixes #91
- Loading branch information
Showing
5 changed files
with
86 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use command_error::CommandExt; | ||
use test_harness::GitProle; | ||
|
||
#[test] | ||
fn add_destination_exists() -> miette::Result<()> { | ||
let prole = GitProle::new().unwrap(); | ||
prole.setup_worktree_repo("my-repo").unwrap(); | ||
|
||
prole.sh(r#" | ||
cd my-repo || exit | ||
mkdir puppy | ||
"#)?; | ||
|
||
prole | ||
.cd_cmd("my-repo/main") | ||
.args(["add", "puppy"]) | ||
.status_checked() | ||
.unwrap_err(); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use command_error::CommandExt; | ||
use test_harness::GitProle; | ||
use test_harness::WorktreeState; | ||
|
||
#[test] | ||
fn config_add_branch_replacements_path_separator() -> miette::Result<()> { | ||
let prole = GitProle::new()?; | ||
prole.setup_worktree_repo("my-repo")?; | ||
prole.write_config( | ||
r#" | ||
[[add.branch_replacements]] | ||
find = "doggy" | ||
replace = "silly" | ||
"#, | ||
)?; | ||
|
||
prole | ||
.cd_cmd("my-repo/main") | ||
.args(["add", "-b", "puppy/doggy"]) | ||
.status_checked() | ||
.unwrap(); | ||
|
||
prole | ||
.repo_state("my-repo") | ||
.worktrees([ | ||
WorktreeState::new_bare(), | ||
WorktreeState::new("main").branch("main"), | ||
// Last component of the result of the replacements is used: | ||
WorktreeState::new("silly") | ||
.branch("puppy/doggy") | ||
.upstream("main"), | ||
]) | ||
.assert(); | ||
|
||
Ok(()) | ||
} |