Skip to content

Commit

Permalink
fix: git reset properly
Browse files Browse the repository at this point in the history
  • Loading branch information
chase-crumbaugh committed Apr 9, 2024
1 parent 2abc7fa commit bc1c8a7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,17 @@ func (g *Git) FindAndCheckoutBranch(branchName string) (string, error) {
}

func (g *Git) Reset(args ...string) error {
logging.Info("Running git reset %s", strings.Join(args, ", "))
// We execute this manually because go-git doesn't support all the options we need
args = append([]string{"reset"}, args...)

logging.Info("Running git %s", strings.Join(args, ", "))

cmd := exec.Command("git", args...)
cmd.Dir = filepath.Join(environment.GetWorkspace(), "repo", environment.GetWorkingDirectory())
cmd.Env = os.Environ()
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("error running `git reset %s`: %w %s", strings.Join(args, ", "), err, string(output))
return fmt.Errorf("error running `git %s`: %w %s", strings.Join(args, ", "), err, string(output))
}

return nil
Expand Down Expand Up @@ -314,7 +316,7 @@ func (g *Git) GetCurrentBranch() (string, error) {
return "", fmt.Errorf("error getting head: %w", err)
}

return head.Name().String(), nil
return head.Name().Short(), nil
}

func (g *Git) DeleteBranch(branchName string) error {
Expand Down

0 comments on commit bc1c8a7

Please sign in to comment.