Skip to content

Commit

Permalink
checkout back when good or bad are invalid in gm repo bisect (#165)
Browse files Browse the repository at this point in the history
this PR makes sure the user get back to where they were before running
`gm repo bisect`, i.e.
- when the `--good` revision is not _good_
- when the `--bad` revision is not _bad_
- when the bisect runs properly, it should start on the same revision as
before the _good_ / _bad_ checks
  • Loading branch information
amtoine authored Jan 25, 2024
1 parent 99a5ef9 commit d1ecc77
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,14 @@ export def "gm repo bisect" [
if not $no_check {
print $"checking that ($good) is good..."
^git checkout $good
try {
do $test
} catch {
let is_good = try {
do $test
true
} catch {
false
}
^git checkout -
if not $is_good {
throw-error {
msg: "invalid_good_revision",
text: "not a good revision",
Expand All @@ -416,13 +421,14 @@ export def "gm repo bisect" [

print $"checking that ($bad) is bad..."
^git checkout $bad
let res = try {
let is_good = try {
do $test
true
} catch {
false
}
if $res {
^git checkout -
if $is_good {
throw-error {
msg: "invalid_bad_revision",
text: "not a bad revision",
Expand Down

0 comments on commit d1ecc77

Please sign in to comment.