Skip to content

Commit

Permalink
try with branch reference name
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Aug 1, 2024
1 parent 7cea6ad commit 97084ec
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions utils/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (gm *GitManager) CheckoutToHash(hash string) error {

func (gm *GitManager) GetBestCommonAncestorHash(baseBranch, headBranch string) (string, error) {
// Get the commit object of the base branch
baseRef, err := gm.localGitRepository.Reference(GetFullBranchName(baseBranch), true)
baseRef, err := gm.localGitRepository.Reference(plumbing.NewBranchReferenceName(baseBranch), true)
if err != nil {
return "", err
}
Expand All @@ -224,8 +224,13 @@ func (gm *GitManager) GetBestCommonAncestorHash(baseBranch, headBranch string) (
return "", err
}
log.Debug(fmt.Sprintf("Found commit %s for base branch %s", baseCommit.Hash.String(), baseBranch))
// Get the commit object of the head branch
headRef, err := gm.localGitRepository.Reference(GetFullBranchName(headBranch), true)
// Get the commit object of the head branch (can have no references, initial commit...)
// headRef, err := gm.localGitRepository.Reference(GetFullBranchName(headBranch), true)
// if err != nil {
// return "", err
// }

headRef, err := gm.localGitRepository.Reference(plumbing.NewBranchReferenceName(headBranch), true)
if err != nil {
return "", err
}
Expand Down

0 comments on commit 97084ec

Please sign in to comment.