Skip to content

Commit 8be3208

Browse files
committed
fix: follow tag to commits
fix anomaly where the tag reference hash is separate from the actual commit hash, these are produced via the release sub command
1 parent cf431d6 commit 8be3208

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

log/gitutils.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package commitlog
44

55
import (
6+
"fmt"
67
"log"
78
"strings"
89

@@ -74,6 +75,19 @@ func isCommitToNearestTag(repo *git.Repository, commit *object.Commit) bool {
7475
}
7576
}
7677

78+
revisionHashLatest, err := repo.ResolveRevision(plumbing.Revision(latestTag.Name()))
79+
if err != nil {
80+
log.Fatal("Error getting the targetted commit for latestTag")
81+
}
82+
revisionHashPrevious, err := repo.ResolveRevision(plumbing.Revision(previousTag.Name()))
83+
if err != nil {
84+
log.Fatal("Error getting the targetted commit for previousTag")
85+
}
86+
87+
if err != nil {
88+
fmt.Println(err)
89+
}
90+
7791
ref, err := repo.Head()
7892

7993
if err != nil {
@@ -88,9 +102,9 @@ func isCommitToNearestTag(repo *git.Repository, commit *object.Commit) bool {
88102

89103
if latestTag != nil && previousTag != nil {
90104
if tillLatest {
91-
return latestTag.Hash() == commit.Hash
105+
return *revisionHashLatest == commit.Hash
92106
}
93-
return previousTag.Hash() == commit.Hash
107+
return *revisionHashPrevious == commit.Hash
94108

95109
}
96110
return false

log/log.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ func CommitLog(path string, startCommitString string, endCommitString string, in
186186

187187
for _, c := range commits {
188188
key, scopedKey := findKeyInCommit(SupportedKeys, c.Message)
189-
fmt.Printf("key: %v,scopedKey:%v \n", key, scopedKey)
190189
key = strings.SplitN(strings.TrimSpace(key), ":", 2)[0]
191190
normalizedHash := c.Hash.String() + " - " + normalizeCommit(c.Message, scopedKey)
192191

@@ -216,7 +215,6 @@ func (inclusions *commitTypeInclusions) checkInclusion(flagToCheck string) bool
216215
func findKeyInCommit(key string, commitMessage string) (string, string) {
217216
re := regexp.MustCompile(`^(` + key + `)[:]|^((` + key + `)\((\w+[, /\\]*)+\)[:])`)
218217
keyMatches := re.FindAllStringSubmatch(commitMessage, -1)
219-
fmt.Printf("%v", keyMatches)
220218
if len(keyMatches) == 0 {
221219
return "", ""
222220
}

0 commit comments

Comments
 (0)