Skip to content

Commit

Permalink
fix: improve close and fix footer parser
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Oct 7, 2021
1 parent 5296cd2 commit 7200e5f
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 25 deletions.
15 changes: 12 additions & 3 deletions 3_transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ type Commit struct {
Author *object.Signature
Committer *object.Signature
Field Message
RevertCommitHash *string // revert hash
RevertCommitHashURL *string // revert hash URL
RevertCommitHash *string // Revert hash
RevertCommitHashURL *string // Revert hash URL
Closes *[]string // Closes issues
}

// https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit-message-header
Expand Down Expand Up @@ -168,7 +169,9 @@ func Transform(g *client.GitClient, splices []*ExtractSplice) ([]*TemplateContex
}

if field.Footer != nil && len(field.Footer) > 0 {
breakingChangeFooter := field.GetFooterByField("BREAKING CHANGE", "BREAKING CHANGES", "BREAKING-CHANGE", "BREAKING-CHANGES")
// Specification
// BREAKING-CHANGE MUST be synonymous with BREAKING CHANGE, when used as a token in a footer.
breakingChangeFooter := field.GetFooterByField("BREAKING CHANGE", "BREAKING-CHANGE")

if breakingChangeFooter != nil {
if ctx.BreakingChanges == nil {
Expand All @@ -183,6 +186,12 @@ func Transform(g *client.GitClient, splices []*ExtractSplice) ([]*TemplateContex
},
}
}

closes := field.GetCloses()

if len(closes) != 0 {
c.Closes = &closes
}
}

if header.Type == "revert" {
Expand Down
2 changes: 0 additions & 2 deletions __test__/whatchanged-[v0.2.0].CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,3 @@
- $ changelog --help
+ $ whatchanged --help
```

Closes #6
2 changes: 0 additions & 2 deletions __test__/whatchanged-[v0.2.0~v0.1.0].CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
+ $ whatchanged --help
```

Closes #6

## v0.1.0 (2020-11-24)

### New feature:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
github.com/go-git/go-git/v5 v5.4.2
github.com/pkg/errors v0.9.1
github.com/release-lab/conventional-commit-parser v0.1.6
github.com/release-lab/conventional-commit-parser v0.1.7
github.com/stretchr/testify v1.7.0
github.com/whilp/git-urls v1.0.0
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ github.com/release-lab/conventional-commit-parser v0.1.5 h1:r4kWlRbh5V4Y0ne3j2A4
github.com/release-lab/conventional-commit-parser v0.1.5/go.mod h1:J56B1fNHAVNm5SynjINkz1mThTKqN0KQnFH54Fuz2KQ=
github.com/release-lab/conventional-commit-parser v0.1.6 h1:GsmmsOBnYtuWubjaTkQYp7KqkvdHNbOirxGtWsUWAww=
github.com/release-lab/conventional-commit-parser v0.1.6/go.mod h1:J56B1fNHAVNm5SynjINkz1mThTKqN0KQnFH54Fuz2KQ=
github.com/release-lab/conventional-commit-parser v0.1.7 h1:aoyrKdOg3rDVhOci6kgqXzLFHV9AJLY58WHbgD3SQaQ=
github.com/release-lab/conventional-commit-parser v0.1.7/go.mod h1:J56B1fNHAVNm5SynjINkz1mThTKqN0KQnFH54Fuz2KQ=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand Down
91 changes: 75 additions & 16 deletions vendor/github.com/release-lab/conventional-commit-parser/parser.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ github.com/pkg/errors
# github.com/pmezard/go-difflib v1.0.0
## explicit
github.com/pmezard/go-difflib/difflib
# github.com/release-lab/conventional-commit-parser v0.1.6
# github.com/release-lab/conventional-commit-parser v0.1.7
## explicit; go 1.17
github.com/release-lab/conventional-commit-parser
# github.com/sergi/go-diff v1.1.0
Expand Down

0 comments on commit 7200e5f

Please sign in to comment.