Skip to content

Commit a9e2b87

Browse files
committed
fix: add blang/semver and GetMergeBase
Signed-off-by: Andrew Brandt <[email protected]>
1 parent bd0f3a0 commit a9e2b87

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

latest/latest.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package latest
22

33
import (
4+
"github.com/blang/semver"
45
"github.com/go-git/go-git/v5"
56
"github.com/go-git/go-git/v5/plumbing"
67
"github.com/pkg/errors"
@@ -110,7 +111,7 @@ func FindLatestVersionOnBranch(repo *git.Repository, majorVersionFilter int, bra
110111
}
111112

112113
// Ensure the commit is on the specified branch
113-
isMerged, err := repo.MergeBase(commit, branchName)
114+
isMerged, err := repo.getMergeBase(commit, branchName)
114115
if err != nil || !isMerged {
115116
return nil // Skip tags not in the default branch history
116117
}
@@ -134,3 +135,13 @@ func FindLatestVersionOnBranch(repo *git.Repository, majorVersionFilter int, bra
134135

135136
return latestVersion, latestTag, nil
136137
}
138+
139+
func getMergeBase(repoPath, branchA, branchB string) (string, error) {
140+
cmd := exec.Command("git", "-C", repoPath, "merge-base", branchA, branchB)
141+
output, err := cmd.Output()
142+
if err != nil {
143+
return "", err
144+
}
145+
return strings.TrimSpace(string(output)), nil
146+
}
147+

0 commit comments

Comments
 (0)