Skip to content
Snippets Groups Projects
Commit e0e132e2 authored by Juhani Ränkimies's avatar Juhani Ränkimies
Browse files

fix: remove duplicate entries from pre-release notes

parent 839cdcc1
No related branches found
No related tags found
No related merge requests found
Pipeline #29872511 passed
......@@ -50,7 +50,7 @@
[[projects]]
branch = "master"
digest = "1:c885f6677be67143920aaa2e2b779011fc93d0acee08e8a6d5e6b75bad0fc65b"
digest = "1:3e26e2b5651595c1842a2665f3d5d80121cba77ed077d093ef2da0ab5c379d8c"
name = "github.com/juranki/go-semrel"
packages = [
"angularcommit",
......@@ -58,7 +58,7 @@
"semrel",
]
pruneopts = "UT"
revision = "21b5861f71391d94f2f58959ae39126b1e0fa3fd"
revision = "bbb7d73376d9b9be3d9198c13fa1020f4a2fbd85"
[[projects]]
digest = "1:19cbd171739c98ab0c6532f340f217ee6aa5c3623e58b7c54d2c3cbff80a3114"
......
......@@ -39,6 +39,7 @@ type fakeFixChange struct {
func (c *fakeFixChange) Category() string { return "fix" }
func (c *fakeFixChange) BumpLevel() semrel.BumpLevel { return semrel.BumpPatch }
func (c *fakeFixChange) PreReleased() bool { return false }
func clientFromContext(c *cli.Context) (*gitlab.Client, error) {
token := c.GlobalString("token")
......@@ -151,6 +152,16 @@ func analyzeCommits(c *cli.Context) (*semrel.ReleaseData, error) {
if err != nil {
return nil, err
}
// Remove commit entries with PreReleased == true
newChanges := make(map[string][]semrel.Change)
for category, changes := range releaseData.Changes {
for _, change := range changes {
if !change.PreReleased() {
newChanges[category] = append(newChanges[category], change)
}
}
}
releaseData.Changes = newChanges
}
}
return releaseData, nil
......
......@@ -62,7 +62,7 @@ func (analyzer *Analyzer) Analyze(commit *semrel.Commit) ([]semrel.Change, error
message := commit.Msg
ac := parseAngularHead(message)
ac.BreakingMessage = parseAngularBreakingChange(message, options.BreakingChangeMarkers)
ac.commit = commit
ac.commit = *commit
ac.options = options
ac.Hash = commit.SHA
if ac.BumpLevel() != semrel.NoBump {
......@@ -79,7 +79,7 @@ type Change struct {
Subject string
BreakingMessage string
Hash string
commit *semrel.Commit
commit semrel.Commit
options *Options
}
......@@ -112,6 +112,11 @@ func (commit *Change) BumpLevel() semrel.BumpLevel {
return semrel.NoBump
}
// PreReleased implements semrel.Change interface
func (commit *Change) PreReleased() bool {
return commit.commit.PreReleased
}
func parseAngularHead(text string) *Change {
t := strings.Replace(text, "\r", "", -1)
if match := fullAngularHead.FindStringSubmatch(t); len(match) > 0 {
......
......@@ -52,6 +52,7 @@ func (a ByTime) Less(i, j int) bool { return a[i].Time.Before(a[j].Time) }
type Change interface {
Category() string
BumpLevel() BumpLevel
PreReleased() bool
}
// ReleaseData contains information for next release
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment