Skip to content

Commit d83c1a9

Browse files
committed
Resolve issue with calculating the next version when latest tag is not on the current branch
Signed-off-by: Andrew Brandt <[email protected]>
1 parent a46104f commit d83c1a9

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

next/next.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
package next
22

33
import (
4-
"github.com/go-git/go-git/v5"
5-
"github.com/go-git/go-git/v5/plumbing"
6-
"github.com/go-git/go-git/v5/plumbing/revlist"
7-
"github.com/pkg/errors"
84
"github.com/andrewb1269hg/git-semver/conventional_commits"
9-
"github.com/andrewb1269hg/git-semver/git_utils"
105
"github.com/andrewb1269hg/git-semver/latest"
116
"github.com/andrewb1269hg/git-semver/logger"
127
"github.com/andrewb1269hg/git-semver/semver"
8+
"github.com/go-git/go-git/v5"
9+
"github.com/go-git/go-git/v5/plumbing"
10+
"github.com/go-git/go-git/v5/plumbing/revlist"
11+
"github.com/pkg/errors"
1312
)
1413

1514
type NextOptions struct {
@@ -41,11 +40,12 @@ func Next(options NextOptions) (*semver.Version, error) {
4140
return nil, errors.WithMessage(err, "Error while trying to find latest release version tag")
4241
}
4342

44-
if latestReleaseVersionTag != nil {
45-
if err = git_utils.AssertRefIsReachable(repo, latestReleaseVersionTag, headRef, "Latest tag is not on HEAD. This is necessary as the next version is calculated based on the commits since the latest version tag."); err != nil {
46-
return nil, err
47-
}
48-
}
43+
// Removed the ancestry check here
44+
// if latestReleaseVersionTag != nil {
45+
// if err = git_utils.AssertRefIsReachable(repo, latestReleaseVersionTag, headRef, "Latest tag is not on HEAD. This is necessary as the next version is calculated based on the commits since the latest version tag."); err != nil {
46+
// return nil, err
47+
// }
48+
// }
4949

5050
if latestReleaseVersion == nil {
5151
latestReleaseVersion = &semver.EmptyVersion
@@ -63,9 +63,10 @@ func Next(options NextOptions) (*semver.Version, error) {
6363
}
6464

6565
if latestPreReleaseVersionTag != nil {
66-
if err = git_utils.AssertRefIsReachable(repo, latestPreReleaseVersionTag, headRef, "Latest tag is not on HEAD. This is necessary as the next version is calculated based on the commits since the latest version tag."); err != nil {
67-
return nil, err
68-
}
66+
// Removed the ancestry check here
67+
// if err = git_utils.AssertRefIsReachable(repo, latestPreReleaseVersionTag, headRef, "Latest tag is not on HEAD. This is necessary as the next version is calculated based on the commits since the latest version tag."); err != nil {
68+
// return nil, err
69+
// }
6970
}
7071

7172
excludedCommits := make([]plumbing.Hash, 0, 1)
@@ -142,7 +143,6 @@ func Next(options NextOptions) (*semver.Version, error) {
142143
}
143144

144145
return &nextVersion, nil
145-
146146
}
147147

148148
func commitMessageToSemverChange(msg *conventional_commits.ConventionalCommitMessage) semver.Change {

0 commit comments

Comments
 (0)