Skip to content

Add support for semver suffixes (X.Y.Z-[prerelease]+[build_number]) #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- List information using info
- Mail Template Command
- Support for semver suffixes (`X.Y.Z-[prerelease]+[build_number]`)

## [0.0.1] - 2017-08-12

Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ TAG=latest
setup:
go get -v ./...
go get github.com/golang/lint/golint
go get github.com/fzipp/gocyclo
go get github.com/fzipp/gocyclo

test:
go test -v ./...
Expand All @@ -17,6 +17,9 @@ test:
clean:
rm kacl-*.tar.gz

build:
go build -o kacl main.go

releases:
GOARCH=amd64 GOOS=linux CGO_ENABLED=0 go build -o kacl main.go && tar czvf kacl-$(TAG)-linux_amd64.tar.gz kacl
GOARCH=386 GOOS=linux CGO_ENABLED=0 go build -o kacl main.go && tar czvf kacl-$(TAG)-linux_386.tar.gz kacl
Expand Down
2 changes: 1 addition & 1 deletion changelog/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (c Contents) ChangeLogInfo(version string) string {

var unreleasedRe = regexp.MustCompile(`(?i)^##\s*\[?(unreleased)\]?\s*$`)
var sectionRe = regexp.MustCompile(`(?i)^###\s(added|changed|deprecated|fixed|removed|security)\s*$`)
var changeRe = regexp.MustCompile(`(?i)^##\s*\[?([0-9.]+)\]?\s*-?\s*([0-9\-]+)?\s*$`)
var changeRe = regexp.MustCompile(`(?i)^##\s*\[?([0-9]+\.[0-9]+\.[0-9]+(?:-[a-zA-Z.0-9]+)?(?:\+[0-9]+)?)\]?\s*-?\s*([0-9\-]+)?\s*$`)
var changeRefRe = regexp.MustCompile(`(?i)^\[([^\]]+)\]:\s*(.*)/compare/(.*)\.\.\.(.*)$`)
var refRe = regexp.MustCompile(`(?i)^\[([^\]]+)\]:\s*(.*)$`)

Expand Down
20 changes: 10 additions & 10 deletions changelog/changelog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- some old stuff
- bad code

## [0.3.0] - 2016-12-03
## [0.3.0-rc1.1+42] - 2016-12-03
### Added
- This awesome feature
- More pewpew.
Expand All @@ -44,8 +44,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- hard coded passwords have been removed
- stack overflow issue solved!

[Unreleased]: https://github.com/myuser/myproject/compare/v0.3.0...HEAD
[0.3.0]: https://github.com/myuser/myproject/compare/v0.2.0...v0.3.0
[Unreleased]: https://github.com/myuser/myproject/compare/v0.3.0-rc1.1+42...HEAD
[0.3.0-rc1.1+42]: https://github.com/myuser/myproject/compare/v0.2.0...v0.3.0-rc1.1+42
[0.2.0]: https://github.com/myuser/myproject/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/myuser/myproject/compare/v0.0.8...v0.1.0
`
Expand All @@ -68,7 +68,7 @@ func TestParse_has_rest(t *testing.T) {
buf := bytes.NewBufferString(testLog1)
contents, err := Parse(buf)
assert.Nil(t, err)
rest := `## [0.3.0] - 2016-12-03
rest := `## [0.3.0-rc1.1+42] - 2016-12-03
### Added
- This awesome feature
- More pewpew.
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestParse_has_changes(t *testing.T) {
- some issue`,
},
&Changes{
Tag: "0.3.0",
Tag: "0.3.0-rc1.1+42",
Added: `- This awesome feature
- More pewpew.`,
Time: time.Date(2016, 12, 3, 0, 0, 0, 0, time.UTC),
Expand Down Expand Up @@ -138,16 +138,16 @@ func TestParse_has_references(t *testing.T) {
expected := []Reference{
{
Tag: "Unreleased",
Raw: "[Unreleased]: https://github.com/myuser/myproject/compare/v0.3.0...HEAD",
From: "v0.3.0",
Raw: "[Unreleased]: https://github.com/myuser/myproject/compare/v0.3.0-rc1.1+42...HEAD",
From: "v0.3.0-rc1.1+42",
To: "HEAD",
BaseURL: "https://github.com/myuser/myproject",
},
{
Tag: "0.3.0",
Raw: "[0.3.0]: https://github.com/myuser/myproject/compare/v0.2.0...v0.3.0",
Tag: "0.3.0-rc1.1+42",
Raw: "[0.3.0-rc1.1+42]: https://github.com/myuser/myproject/compare/v0.2.0...v0.3.0-rc1.1+42",
From: "v0.2.0",
To: "v0.3.0",
To: "v0.3.0-rc1.1+42",
BaseURL: "https://github.com/myuser/myproject",
},
{
Expand Down
11 changes: 11 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/xurei/kacl

go 1.15

require (
github.com/fatih/color v1.10.0
github.com/mitchellh/go-homedir v1.1.0
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.1
github.com/stretchr/testify v1.6.1
)
Loading