Skip to content

Commit

Permalink
[MER-2497] Abort git-cherry-pick on --abort (#184)
Browse files Browse the repository at this point in the history
Tested manually with a local repo. This won't restore the branch state, but
aborts the in-progress cherry-pick.
  • Loading branch information
draftcode authored Jun 26, 2023
1 parent f7f39da commit b40636c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions cmd/av/stack_reorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import (
"bufio"
"fmt"
"os"
"path/filepath"
"strings"

"github.com/aviator-co/av/internal/git"

"emperror.dev/errors"
"github.com/aviator-co/av/internal/actions"
"github.com/aviator-co/av/internal/config"
"github.com/aviator-co/av/internal/git"
"github.com/aviator-co/av/internal/meta"
"github.com/aviator-co/av/internal/reorder"
"github.com/aviator-co/av/internal/utils/colors"
"github.com/sirupsen/logrus"

"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -66,7 +66,16 @@ var stackReorderCmd = &cobra.Command{

var state *reorder.State
if stackReorderFlags.Abort {
// TODO: Handle clearing any cherry-pick state and whatnot.
if continuation == nil {
_ = reorder.WriteContinuation(repo, nil)
return errors.New("no reorder in progress")
}

if stat, _ := os.Stat(filepath.Join(repo.GitDir(), "CHERRY_PICK_HEAD")); stat != nil {
if err := repo.CherryPick(git.CherryPick{Resume: git.CherryPickAbort}); err != nil {
return errors.WrapIf(err, "failed to abort in-progress cherry-pick")
}
}
// TODO: --abort should probably reset the state of each branch
// associated with the reorder to the original. It might be worth
// storing some history and allow the user to do --undo to restore
Expand Down

0 comments on commit b40636c

Please sign in to comment.