You've already forked go-semantic-release
feat(analyzer): add conventional commit format
See: [conventional](https://www.conventionalcommits.org/en/v1.0.0/#summaryhttps://www.conventionalcommits.org/en/v1.0.0/#summary)
This commit is contained in:
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
|||||||
- name: Lint
|
- name: Lint
|
||||||
run: |
|
run: |
|
||||||
export PATH=$PATH:$(go env GOPATH)/bin
|
export PATH=$PATH:$(go env GOPATH)/bin
|
||||||
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.30.0
|
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.35.3
|
||||||
golangci-lint run ./...
|
golangci-lint run ./...
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
|||||||
17
README.md
17
README.md
@@ -60,11 +60,20 @@ hooks:
|
|||||||
|
|
||||||
#### CommitFormat
|
#### CommitFormat
|
||||||
|
|
||||||
Set the commit format, at the moment we support ony [angular](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit-message-format), more coming soon.
|
Supported formats:
|
||||||
|
|
||||||
|
* [angular](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit-message-format)
|
||||||
|
|
||||||
|
```yml
|
||||||
|
commitFormat: angular
|
||||||
|
```
|
||||||
|
|
||||||
|
* [conventional](https://www.conventionalcommits.org/en/v1.0.0/#summaryhttps://www.conventionalcommits.org/en/v1.0.0/#summary)
|
||||||
|
|
||||||
|
```yml
|
||||||
|
commitFormat: conventional
|
||||||
|
```
|
||||||
|
|
||||||
```yml
|
|
||||||
commitFormat: angular
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Branch
|
#### Branch
|
||||||
|
|
||||||
|
|||||||
15
go.mod
15
go.mod
@@ -4,7 +4,7 @@ go 1.13
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Masterminds/semver v1.5.0
|
github.com/Masterminds/semver v1.5.0
|
||||||
github.com/Microsoft/go-winio v0.4.15 // indirect
|
github.com/Microsoft/go-winio v0.4.16 // indirect
|
||||||
github.com/go-git/go-billy/v5 v5.0.0
|
github.com/go-git/go-billy/v5 v5.0.0
|
||||||
github.com/go-git/go-git/v5 v5.2.0
|
github.com/go-git/go-git/v5 v5.2.0
|
||||||
github.com/golang/protobuf v1.4.3 // indirect
|
github.com/golang/protobuf v1.4.3 // indirect
|
||||||
@@ -14,12 +14,13 @@ require (
|
|||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/sirupsen/logrus v1.7.0
|
github.com/sirupsen/logrus v1.7.0
|
||||||
github.com/spf13/cobra v1.1.1
|
github.com/spf13/cobra v1.1.1
|
||||||
github.com/stretchr/testify v1.4.0
|
github.com/stretchr/testify v1.7.0
|
||||||
github.com/xanzy/ssh-agent v0.3.0 // indirect
|
github.com/xanzy/ssh-agent v0.3.0 // indirect
|
||||||
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect
|
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
|
||||||
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102 // indirect
|
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect
|
||||||
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43
|
golang.org/x/oauth2 v0.0.0-20210113205817-d3ed898aa8a3
|
||||||
golang.org/x/sys v0.0.0-20201107080550-4d91cf3a1aaf // indirect
|
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 // indirect
|
||||||
google.golang.org/appengine v1.6.7 // indirect
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
gopkg.in/yaml.v2 v2.3.0
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
33
go.sum
33
go.sum
@@ -38,8 +38,8 @@ github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3Q
|
|||||||
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
||||||
github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU=
|
github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU=
|
||||||
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
|
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
|
||||||
github.com/Microsoft/go-winio v0.4.15 h1:qkLXKzb1QoVatRyd/YlXZ/Kg0m5K3SPuoD82jjSOaBc=
|
github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk=
|
||||||
github.com/Microsoft/go-winio v0.4.15/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw=
|
github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
|
||||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||||
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
|
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
|
||||||
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
|
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
|
||||||
@@ -288,6 +288,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
|
|||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||||
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
|
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
|
||||||
@@ -316,8 +318,8 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
|
|||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E=
|
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY=
|
||||||
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||||
@@ -378,16 +380,16 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/
|
|||||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102 h1:42cLlJJdEh+ySyeUUbEQ5bsTiq8voBeTuweGVkY6Puw=
|
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 h1:003p0dJM77cxMSyCPFphvZf/Y5/NXf5fzg6ufd1/Oew=
|
||||||
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw=
|
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw=
|
||||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 h1:ld7aEMNHoBnnDAX15v1T6z31v8HwR2A9FYOuAhWqkwc=
|
golang.org/x/oauth2 v0.0.0-20210113205817-d3ed898aa8a3 h1:BaN3BAqnopnKjvl+15DYP6LLrbBHfbfmlFYzmFj/Q9Q=
|
||||||
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
golang.org/x/oauth2 v0.0.0-20210113205817-d3ed898aa8a3/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
@@ -429,9 +431,12 @@ golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201107080550-4d91cf3a1aaf h1:kt3wY1Lu5MJAnKTfoMR52Cu4gwvna4VTzNOiT8tY73s=
|
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 h1:myAQVi0cGEoqQVR5POX+8RR2mrocKqNN1hmeMqhX27k=
|
||||||
golang.org/x/sys v0.0.0-20201107080550-4d91cf3a1aaf/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
@@ -588,6 +593,12 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ func New(format string, config config.ChangelogConfig) (*Analyzer, error) {
|
|||||||
case ANGULAR:
|
case ANGULAR:
|
||||||
analyzer.analyzeCommits = newAngular()
|
analyzer.analyzeCommits = newAngular()
|
||||||
log.Debugf("Commit format set to %s", ANGULAR)
|
log.Debugf("Commit format set to %s", ANGULAR)
|
||||||
|
case CONVENTIONAL:
|
||||||
|
analyzer.analyzeCommits = newConventional()
|
||||||
|
log.Debugf("Commit format set to %s", CONVENTIONAL)
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("invalid commit format: %s", format)
|
return nil, fmt.Errorf("invalid commit format: %s", format)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ type angular struct {
|
|||||||
log *log.Entry
|
log *log.Entry
|
||||||
}
|
}
|
||||||
|
|
||||||
// ANGULAR identifer
|
// ANGULAR identifier
|
||||||
const ANGULAR = "angular"
|
const ANGULAR = "angular"
|
||||||
|
|
||||||
func newAngular() *angular {
|
func newAngular() *angular {
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ func TestAngular(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testCase: "feat",
|
testCase: "feat",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"minor": []shared.AnalyzedCommit{
|
"minor": {
|
||||||
shared.AnalyzedCommit{
|
{
|
||||||
Commit: shared.Commit{
|
Commit: shared.Commit{
|
||||||
Message: "feat(internal/changelog): my first commit",
|
Message: "feat(internal/changelog): my first commit",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
@@ -33,12 +33,12 @@ func TestAngular(t *testing.T) {
|
|||||||
Print: true,
|
Print: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"major": []shared.AnalyzedCommit{},
|
"major": {},
|
||||||
"patch": []shared.AnalyzedCommit{},
|
"patch": {},
|
||||||
"none": []shared.AnalyzedCommit{},
|
"none": {},
|
||||||
},
|
},
|
||||||
commits: []shared.Commit{
|
commits: []shared.Commit{
|
||||||
shared.Commit{
|
{
|
||||||
Message: "feat(internal/changelog): my first commit",
|
Message: "feat(internal/changelog): my first commit",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
Hash: "12345667",
|
Hash: "12345667",
|
||||||
@@ -48,8 +48,8 @@ func TestAngular(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testCase: "feat breaking change",
|
testCase: "feat breaking change",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"minor": []shared.AnalyzedCommit{
|
"minor": {
|
||||||
shared.AnalyzedCommit{
|
{
|
||||||
Commit: shared.Commit{
|
Commit: shared.Commit{
|
||||||
Message: "feat(internal/changelog): my first commit",
|
Message: "feat(internal/changelog): my first commit",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
@@ -62,8 +62,8 @@ func TestAngular(t *testing.T) {
|
|||||||
Print: true,
|
Print: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"major": []shared.AnalyzedCommit{
|
"major": {
|
||||||
shared.AnalyzedCommit{
|
{
|
||||||
Commit: shared.Commit{
|
Commit: shared.Commit{
|
||||||
Message: "feat(internal/changelog): my first break BREAKING CHANGE: change api to v2",
|
Message: "feat(internal/changelog): my first break BREAKING CHANGE: change api to v2",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
@@ -77,38 +77,38 @@ func TestAngular(t *testing.T) {
|
|||||||
ParsedBreakingChangeMessage: "change api to v2",
|
ParsedBreakingChangeMessage: "change api to v2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"patch": []shared.AnalyzedCommit{},
|
"patch": {},
|
||||||
"none": []shared.AnalyzedCommit{},
|
"none": {},
|
||||||
},
|
},
|
||||||
commits: []shared.Commit{
|
commits: []shared.Commit{
|
||||||
shared.Commit{
|
{
|
||||||
Message: "feat(internal/changelog): my first commit",
|
Message: "feat(internal/changelog): my first commit",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
Hash: "12345667",
|
Hash: "12345667",
|
||||||
},
|
},
|
||||||
shared.Commit{
|
{
|
||||||
Message: "feat(internal/changelog): my first break BREAKING CHANGE: change api to v2",
|
Message: "feat(internal/changelog): my first break BREAKING CHANGE: change api to v2",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
Hash: "12345668",
|
Hash: "12345668",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ testCase: "feat breaking change footer",
|
{testCase: "feat breaking change footer",
|
||||||
commits: []shared.Commit{
|
commits: []shared.Commit{
|
||||||
shared.Commit{
|
{
|
||||||
Message: "feat(internal/changelog): my first commit",
|
Message: "feat(internal/changelog): my first commit",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
Hash: "12345667",
|
Hash: "12345667",
|
||||||
},
|
},
|
||||||
shared.Commit{
|
{
|
||||||
Message: "feat(internal/changelog): my first break \n\nBREAKING CHANGE: change api to v2\n",
|
Message: "feat(internal/changelog): my first break \n\nBREAKING CHANGE: change api to v2\n",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
Hash: "12345668",
|
Hash: "12345668",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"minor": []shared.AnalyzedCommit{
|
"minor": {
|
||||||
shared.AnalyzedCommit{
|
{
|
||||||
Commit: shared.Commit{
|
Commit: shared.Commit{
|
||||||
Message: "feat(internal/changelog): my first commit",
|
Message: "feat(internal/changelog): my first commit",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
@@ -121,8 +121,8 @@ func TestAngular(t *testing.T) {
|
|||||||
Print: true,
|
Print: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"major": []shared.AnalyzedCommit{
|
"major": {
|
||||||
shared.AnalyzedCommit{
|
{
|
||||||
Commit: shared.Commit{
|
Commit: shared.Commit{
|
||||||
Message: "feat(internal/changelog): my first break \n\nBREAKING CHANGE: change api to v2\n",
|
Message: "feat(internal/changelog): my first break \n\nBREAKING CHANGE: change api to v2\n",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
@@ -136,25 +136,25 @@ func TestAngular(t *testing.T) {
|
|||||||
ParsedBreakingChangeMessage: "change api to v2",
|
ParsedBreakingChangeMessage: "change api to v2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"patch": []shared.AnalyzedCommit{},
|
"patch": {},
|
||||||
"none": []shared.AnalyzedCommit{},
|
"none": {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
testCase: "invalid",
|
testCase: "invalid",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"minor": []shared.AnalyzedCommit{},
|
"minor": {},
|
||||||
"major": []shared.AnalyzedCommit{},
|
"major": {},
|
||||||
"patch": []shared.AnalyzedCommit{},
|
"patch": {},
|
||||||
"none": []shared.AnalyzedCommit{},
|
"none": {},
|
||||||
},
|
},
|
||||||
commits: []shared.Commit{
|
commits: []shared.Commit{
|
||||||
shared.Commit{
|
{
|
||||||
Message: "internal/changelog: my first commit",
|
Message: "internal/changelog: my first commit",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
Hash: "12345667",
|
Hash: "12345667",
|
||||||
},
|
},
|
||||||
shared.Commit{
|
{
|
||||||
Message: "Merge feat(internal/changelog): my first commit",
|
Message: "Merge feat(internal/changelog): my first commit",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
Hash: "12345667",
|
Hash: "12345667",
|
||||||
@@ -164,8 +164,8 @@ func TestAngular(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testCase: "feat and build",
|
testCase: "feat and build",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"minor": []shared.AnalyzedCommit{
|
"minor": {
|
||||||
shared.AnalyzedCommit{
|
{
|
||||||
Commit: shared.Commit{
|
Commit: shared.Commit{
|
||||||
Message: "feat(internal/changelog): my first commit",
|
Message: "feat(internal/changelog): my first commit",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
@@ -178,8 +178,8 @@ func TestAngular(t *testing.T) {
|
|||||||
Print: true,
|
Print: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"none": []shared.AnalyzedCommit{
|
"none": {
|
||||||
shared.AnalyzedCommit{
|
{
|
||||||
Commit: shared.Commit{
|
Commit: shared.Commit{
|
||||||
Message: "build(internal/changelog): my first build",
|
Message: "build(internal/changelog): my first build",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
@@ -193,16 +193,16 @@ func TestAngular(t *testing.T) {
|
|||||||
ParsedBreakingChangeMessage: "",
|
ParsedBreakingChangeMessage: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"patch": []shared.AnalyzedCommit{},
|
"patch": {},
|
||||||
"major": []shared.AnalyzedCommit{},
|
"major": {},
|
||||||
},
|
},
|
||||||
commits: []shared.Commit{
|
commits: []shared.Commit{
|
||||||
shared.Commit{
|
{
|
||||||
Message: "feat(internal/changelog): my first commit",
|
Message: "feat(internal/changelog): my first commit",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
Hash: "12345667",
|
Hash: "12345667",
|
||||||
},
|
},
|
||||||
shared.Commit{
|
{
|
||||||
Message: "build(internal/changelog): my first build",
|
Message: "build(internal/changelog): my first build",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
Hash: "12345668",
|
Hash: "12345668",
|
||||||
|
|||||||
130
internal/analyzer/conventional.go
Normal file
130
internal/analyzer/conventional.go
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
// Package analyzer provides different commit analyzer
|
||||||
|
package analyzer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/Nightapes/go-semantic-release/internal/shared"
|
||||||
|
)
|
||||||
|
|
||||||
|
type conventional struct {
|
||||||
|
rules []Rule
|
||||||
|
regex string
|
||||||
|
log *log.Entry
|
||||||
|
}
|
||||||
|
|
||||||
|
// CONVENTIONAL identifier
|
||||||
|
const CONVENTIONAL = "conventional"
|
||||||
|
|
||||||
|
func newConventional() *conventional {
|
||||||
|
return &conventional{
|
||||||
|
regex: `^(TAG)(?:\((.*)\))?(\!)?: (?s)(.*)`,
|
||||||
|
log: log.WithField("analyzer", CONVENTIONAL),
|
||||||
|
rules: []Rule{
|
||||||
|
{
|
||||||
|
Tag: "feat",
|
||||||
|
TagString: "Features",
|
||||||
|
Release: "minor",
|
||||||
|
Changelog: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Tag: "fix",
|
||||||
|
TagString: "Bug fixes",
|
||||||
|
Release: "patch",
|
||||||
|
Changelog: true,
|
||||||
|
}, {
|
||||||
|
Tag: "perf",
|
||||||
|
TagString: "Performance improvments",
|
||||||
|
Release: "patch",
|
||||||
|
Changelog: true,
|
||||||
|
}, {
|
||||||
|
Tag: "docs",
|
||||||
|
TagString: "Documentation changes",
|
||||||
|
Release: "none",
|
||||||
|
Changelog: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Tag: "style",
|
||||||
|
TagString: "Style",
|
||||||
|
Release: "none",
|
||||||
|
Changelog: false,
|
||||||
|
}, {
|
||||||
|
Tag: "refactor",
|
||||||
|
TagString: "Code refactor",
|
||||||
|
Release: "none",
|
||||||
|
Changelog: false,
|
||||||
|
}, {
|
||||||
|
Tag: "test",
|
||||||
|
TagString: "Testing",
|
||||||
|
Release: "none",
|
||||||
|
Changelog: false,
|
||||||
|
}, {
|
||||||
|
Tag: "chore",
|
||||||
|
TagString: "Changes to the build process or auxiliary tools and libraries such as documentation generation",
|
||||||
|
Release: "none",
|
||||||
|
Changelog: false,
|
||||||
|
}, {
|
||||||
|
Tag: "build",
|
||||||
|
TagString: "Changes to CI/CD",
|
||||||
|
Release: "none",
|
||||||
|
Changelog: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *conventional) getRules() []Rule {
|
||||||
|
return a.rules
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *conventional) analyze(commit shared.Commit, rule Rule) (shared.AnalyzedCommit, bool, error) {
|
||||||
|
|
||||||
|
analyzed := shared.AnalyzedCommit{
|
||||||
|
Commit: commit,
|
||||||
|
Tag: rule.Tag,
|
||||||
|
TagString: rule.TagString,
|
||||||
|
}
|
||||||
|
|
||||||
|
re := regexp.MustCompile(strings.Replace(a.regex, "TAG", rule.Tag, -1))
|
||||||
|
matches := re.FindAllStringSubmatch(commit.Message, -1)
|
||||||
|
if len(matches) >= 1 {
|
||||||
|
if len(matches[0]) >= 4 {
|
||||||
|
|
||||||
|
analyzed.Scope = shared.Scope(matches[0][2])
|
||||||
|
|
||||||
|
message := strings.Join(matches[0][4:], "")
|
||||||
|
if matches[0][3] == "" && !strings.Contains(message, "BREAKING CHANGE:") {
|
||||||
|
analyzed.ParsedMessage = strings.Trim(message, " ")
|
||||||
|
|
||||||
|
a.log.Tracef("%s: found %s", commit.Message, rule.Tag)
|
||||||
|
return analyzed, false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if matches[0][3] == "" {
|
||||||
|
breakingChange := strings.SplitN(message, "BREAKING CHANGE:", 2)
|
||||||
|
analyzed.ParsedMessage = strings.TrimSpace(breakingChange[0])
|
||||||
|
analyzed.ParsedBreakingChangeMessage = strings.TrimSpace(breakingChange[1])
|
||||||
|
a.log.Tracef(" %s, BREAKING CHANGE found", commit.Message)
|
||||||
|
return analyzed, true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
breakingChange := strings.SplitN(message, "BREAKING CHANGE:", 2)
|
||||||
|
|
||||||
|
if len(breakingChange) > 1 {
|
||||||
|
analyzed.ParsedMessage = strings.TrimSpace(breakingChange[0])
|
||||||
|
analyzed.ParsedBreakingChangeMessage = strings.TrimSpace(breakingChange[1])
|
||||||
|
} else {
|
||||||
|
analyzed.ParsedBreakingChangeMessage = breakingChange[0]
|
||||||
|
}
|
||||||
|
a.log.Infof(" %s, BREAKING CHANGE found", commit.Message)
|
||||||
|
return analyzed, true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a.log.Tracef("%s does not match %s, skip", commit.Message, rule.Tag)
|
||||||
|
return analyzed, false, fmt.Errorf("not found")
|
||||||
|
|
||||||
|
}
|
||||||
261
internal/analyzer/conventional_test.go
Normal file
261
internal/analyzer/conventional_test.go
Normal file
@@ -0,0 +1,261 @@
|
|||||||
|
package analyzer_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Nightapes/go-semantic-release/internal/analyzer"
|
||||||
|
"github.com/Nightapes/go-semantic-release/internal/shared"
|
||||||
|
"github.com/Nightapes/go-semantic-release/pkg/config"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestConventional(t *testing.T) {
|
||||||
|
|
||||||
|
testConfigs := []struct {
|
||||||
|
testCase string
|
||||||
|
commits []shared.Commit
|
||||||
|
analyzedCommits map[shared.Release][]shared.AnalyzedCommit
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
testCase: "feat",
|
||||||
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
|
"minor": {
|
||||||
|
{
|
||||||
|
Commit: shared.Commit{
|
||||||
|
Message: "feat(internal/changelog): my first commit",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345667",
|
||||||
|
},
|
||||||
|
Scope: "internal/changelog",
|
||||||
|
ParsedMessage: "my first commit",
|
||||||
|
Tag: "feat",
|
||||||
|
TagString: "Features",
|
||||||
|
Print: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Commit: shared.Commit{
|
||||||
|
Message: "feat: no scope",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345667",
|
||||||
|
},
|
||||||
|
Scope: "",
|
||||||
|
ParsedMessage: "no scope",
|
||||||
|
Tag: "feat",
|
||||||
|
TagString: "Features",
|
||||||
|
Print: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"major": {},
|
||||||
|
"patch": {},
|
||||||
|
"none": {},
|
||||||
|
},
|
||||||
|
commits: []shared.Commit{
|
||||||
|
{
|
||||||
|
Message: "feat(internal/changelog): my first commit",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345667",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Message: "feat: no scope",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345667",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testCase: "feat breaking change",
|
||||||
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
|
"minor": {
|
||||||
|
{
|
||||||
|
Commit: shared.Commit{
|
||||||
|
Message: "feat: my first commit",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345667",
|
||||||
|
},
|
||||||
|
Scope: "",
|
||||||
|
ParsedMessage: "my first commit",
|
||||||
|
Tag: "feat",
|
||||||
|
TagString: "Features",
|
||||||
|
Print: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"major": {
|
||||||
|
{
|
||||||
|
Commit: shared.Commit{
|
||||||
|
Message: "feat!: my first break",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345668",
|
||||||
|
},
|
||||||
|
Scope: "",
|
||||||
|
ParsedMessage: "",
|
||||||
|
Tag: "feat",
|
||||||
|
TagString: "Features",
|
||||||
|
Print: true,
|
||||||
|
ParsedBreakingChangeMessage: "my first break",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"patch": {},
|
||||||
|
"none": {},
|
||||||
|
},
|
||||||
|
commits: []shared.Commit{
|
||||||
|
{
|
||||||
|
Message: "feat: my first commit",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345667",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Message: "feat!: my first break",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345668",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testCase: "feat breaking change footer",
|
||||||
|
commits: []shared.Commit{
|
||||||
|
{
|
||||||
|
Message: "feat: my first commit",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345667",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Message: "feat: my first break \n\nBREAKING CHANGE: change api to v2\n",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345668",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Message: "feat!: my first break \n\nBREAKING CHANGE: hey from the change",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345669",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
|
"minor": {
|
||||||
|
{
|
||||||
|
Commit: shared.Commit{
|
||||||
|
Message: "feat: my first commit",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345667",
|
||||||
|
},
|
||||||
|
Scope: "",
|
||||||
|
ParsedMessage: "my first commit",
|
||||||
|
Tag: "feat",
|
||||||
|
TagString: "Features",
|
||||||
|
Print: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"major": {
|
||||||
|
{
|
||||||
|
Commit: shared.Commit{
|
||||||
|
Message: "feat: my first break \n\nBREAKING CHANGE: change api to v2\n",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345668",
|
||||||
|
},
|
||||||
|
Scope: "",
|
||||||
|
ParsedMessage: "my first break",
|
||||||
|
Tag: "feat",
|
||||||
|
TagString: "Features",
|
||||||
|
Print: true,
|
||||||
|
ParsedBreakingChangeMessage: "change api to v2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Commit: shared.Commit{
|
||||||
|
Message: "feat!: my first break \n\nBREAKING CHANGE: hey from the change",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345669",
|
||||||
|
},
|
||||||
|
Scope: "",
|
||||||
|
ParsedMessage: "my first break",
|
||||||
|
Tag: "feat",
|
||||||
|
TagString: "Features",
|
||||||
|
Print: true,
|
||||||
|
ParsedBreakingChangeMessage: "hey from the change",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"patch": {},
|
||||||
|
"none": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testCase: "invalid",
|
||||||
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
|
"minor": {},
|
||||||
|
"major": {},
|
||||||
|
"patch": {},
|
||||||
|
"none": {},
|
||||||
|
},
|
||||||
|
commits: []shared.Commit{
|
||||||
|
{
|
||||||
|
Message: "internal/changelog: my first commit",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345667",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Message: "Merge feat: my first commit",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345667",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testCase: "feat and build",
|
||||||
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
|
"minor": {
|
||||||
|
{
|
||||||
|
Commit: shared.Commit{
|
||||||
|
Message: "feat: my first commit",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345667",
|
||||||
|
},
|
||||||
|
Scope: "",
|
||||||
|
ParsedMessage: "my first commit",
|
||||||
|
Tag: "feat",
|
||||||
|
TagString: "Features",
|
||||||
|
Print: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"none": {
|
||||||
|
{
|
||||||
|
Commit: shared.Commit{
|
||||||
|
Message: "build: my first build",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345668",
|
||||||
|
},
|
||||||
|
Scope: "",
|
||||||
|
ParsedMessage: "my first build",
|
||||||
|
Tag: "build",
|
||||||
|
TagString: "Changes to CI/CD",
|
||||||
|
Print: false,
|
||||||
|
ParsedBreakingChangeMessage: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"patch": {},
|
||||||
|
"major": {},
|
||||||
|
},
|
||||||
|
commits: []shared.Commit{
|
||||||
|
{
|
||||||
|
Message: "feat: my first commit",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345667",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Message: "build: my first build",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345668",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
conventional, err := analyzer.New("conventional", config.ChangelogConfig{})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
for _, test := range testConfigs {
|
||||||
|
analyzedCommits := conventional.Analyze(test.commits)
|
||||||
|
assert.Equalf(t, test.analyzedCommits["major"], analyzedCommits["major"], "Testcase %s should have major commits", test.testCase)
|
||||||
|
assert.Equalf(t, test.analyzedCommits["minor"], analyzedCommits["minor"], "Testcase %s should have minor commits", test.testCase)
|
||||||
|
assert.Equalf(t, test.analyzedCommits["patch"], analyzedCommits["patch"], "Testcase %s should have patch commits", test.testCase)
|
||||||
|
assert.Equalf(t, test.analyzedCommits["none"], analyzedCommits["none"], "Testcase %s should have none commits", test.testCase)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
4
internal/cache/cache_test.go
vendored
4
internal/cache/cache_test.go
vendored
@@ -56,8 +56,8 @@ func TestWriteAndReadCache(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Branch: "master",
|
Branch: "master",
|
||||||
Commits: map[shared.Release][]shared.AnalyzedCommit{
|
Commits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"major": []shared.AnalyzedCommit{
|
"major": {
|
||||||
shared.AnalyzedCommit{
|
{
|
||||||
Commit: shared.Commit{
|
Commit: shared.Commit{
|
||||||
Message: "Message",
|
Message: "Message",
|
||||||
Author: "Author",
|
Author: "Author",
|
||||||
|
|||||||
@@ -83,12 +83,12 @@ func TestCalculator_CalculateNewVersion(t *testing.T) {
|
|||||||
lastVersion: createVersion("1.0.0"),
|
lastVersion: createVersion("1.0.0"),
|
||||||
nextVersion: "1.1.0-alpha.0",
|
nextVersion: "1.1.0-alpha.0",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"major": []shared.AnalyzedCommit{},
|
"major": {},
|
||||||
"minor": []shared.AnalyzedCommit{
|
"minor": {
|
||||||
shared.AnalyzedCommit{},
|
{},
|
||||||
},
|
},
|
||||||
"patch": []shared.AnalyzedCommit{},
|
"patch": {},
|
||||||
"none": []shared.AnalyzedCommit{},
|
"none": {},
|
||||||
},
|
},
|
||||||
isFirst: false,
|
isFirst: false,
|
||||||
},
|
},
|
||||||
@@ -98,12 +98,12 @@ func TestCalculator_CalculateNewVersion(t *testing.T) {
|
|||||||
lastVersion: createVersion("1.0.0"),
|
lastVersion: createVersion("1.0.0"),
|
||||||
nextVersion: "1.1.0-beta.0",
|
nextVersion: "1.1.0-beta.0",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"major": []shared.AnalyzedCommit{},
|
"major": {},
|
||||||
"minor": []shared.AnalyzedCommit{
|
"minor": {
|
||||||
shared.AnalyzedCommit{},
|
{},
|
||||||
},
|
},
|
||||||
"patch": []shared.AnalyzedCommit{},
|
"patch": {},
|
||||||
"none": []shared.AnalyzedCommit{},
|
"none": {},
|
||||||
},
|
},
|
||||||
isFirst: false,
|
isFirst: false,
|
||||||
},
|
},
|
||||||
@@ -113,10 +113,10 @@ func TestCalculator_CalculateNewVersion(t *testing.T) {
|
|||||||
lastVersion: createVersion("1.0.0"),
|
lastVersion: createVersion("1.0.0"),
|
||||||
nextVersion: "1.0.0",
|
nextVersion: "1.0.0",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"major": []shared.AnalyzedCommit{},
|
"major": {},
|
||||||
"minor": []shared.AnalyzedCommit{},
|
"minor": {},
|
||||||
"patch": []shared.AnalyzedCommit{},
|
"patch": {},
|
||||||
"none": []shared.AnalyzedCommit{},
|
"none": {},
|
||||||
},
|
},
|
||||||
isFirst: false,
|
isFirst: false,
|
||||||
},
|
},
|
||||||
@@ -126,10 +126,10 @@ func TestCalculator_CalculateNewVersion(t *testing.T) {
|
|||||||
lastVersion: createVersion("1.0.0"),
|
lastVersion: createVersion("1.0.0"),
|
||||||
nextVersion: "1.0.0",
|
nextVersion: "1.0.0",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"major": []shared.AnalyzedCommit{shared.AnalyzedCommit{}},
|
"major": {{}},
|
||||||
"minor": []shared.AnalyzedCommit{},
|
"minor": {},
|
||||||
"patch": []shared.AnalyzedCommit{},
|
"patch": {},
|
||||||
"none": []shared.AnalyzedCommit{},
|
"none": {},
|
||||||
},
|
},
|
||||||
isFirst: true,
|
isFirst: true,
|
||||||
},
|
},
|
||||||
@@ -139,10 +139,10 @@ func TestCalculator_CalculateNewVersion(t *testing.T) {
|
|||||||
lastVersion: createVersion("1.0.0"),
|
lastVersion: createVersion("1.0.0"),
|
||||||
nextVersion: "2.0.0-rc.0",
|
nextVersion: "2.0.0-rc.0",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"major": []shared.AnalyzedCommit{shared.AnalyzedCommit{}},
|
"major": {{}},
|
||||||
"minor": []shared.AnalyzedCommit{shared.AnalyzedCommit{}},
|
"minor": {{}},
|
||||||
"patch": []shared.AnalyzedCommit{shared.AnalyzedCommit{}},
|
"patch": {{}},
|
||||||
"none": []shared.AnalyzedCommit{},
|
"none": {},
|
||||||
},
|
},
|
||||||
isFirst: false,
|
isFirst: false,
|
||||||
},
|
},
|
||||||
@@ -152,10 +152,10 @@ func TestCalculator_CalculateNewVersion(t *testing.T) {
|
|||||||
lastVersion: createVersion("1.0.0-rc.0"),
|
lastVersion: createVersion("1.0.0-rc.0"),
|
||||||
nextVersion: "1.0.0-rc.1",
|
nextVersion: "1.0.0-rc.1",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"major": []shared.AnalyzedCommit{},
|
"major": {},
|
||||||
"minor": []shared.AnalyzedCommit{shared.AnalyzedCommit{}},
|
"minor": {{}},
|
||||||
"patch": []shared.AnalyzedCommit{shared.AnalyzedCommit{}},
|
"patch": {{}},
|
||||||
"none": []shared.AnalyzedCommit{},
|
"none": {},
|
||||||
},
|
},
|
||||||
isFirst: false,
|
isFirst: false,
|
||||||
},
|
},
|
||||||
@@ -165,10 +165,10 @@ func TestCalculator_CalculateNewVersion(t *testing.T) {
|
|||||||
lastVersion: createVersion("1.0.0"),
|
lastVersion: createVersion("1.0.0"),
|
||||||
nextVersion: "2.0.0",
|
nextVersion: "2.0.0",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"major": []shared.AnalyzedCommit{shared.AnalyzedCommit{}},
|
"major": {{}},
|
||||||
"minor": []shared.AnalyzedCommit{shared.AnalyzedCommit{}},
|
"minor": {{}},
|
||||||
"patch": []shared.AnalyzedCommit{shared.AnalyzedCommit{}},
|
"patch": {{}},
|
||||||
"none": []shared.AnalyzedCommit{},
|
"none": {},
|
||||||
},
|
},
|
||||||
isFirst: false,
|
isFirst: false,
|
||||||
},
|
},
|
||||||
@@ -178,10 +178,10 @@ func TestCalculator_CalculateNewVersion(t *testing.T) {
|
|||||||
lastVersion: createVersion("1.0.0"),
|
lastVersion: createVersion("1.0.0"),
|
||||||
nextVersion: "1.1.0",
|
nextVersion: "1.1.0",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"major": []shared.AnalyzedCommit{},
|
"major": {},
|
||||||
"minor": []shared.AnalyzedCommit{shared.AnalyzedCommit{}},
|
"minor": {{}},
|
||||||
"patch": []shared.AnalyzedCommit{shared.AnalyzedCommit{}},
|
"patch": {{}},
|
||||||
"none": []shared.AnalyzedCommit{},
|
"none": {},
|
||||||
},
|
},
|
||||||
isFirst: false,
|
isFirst: false,
|
||||||
},
|
},
|
||||||
@@ -191,10 +191,10 @@ func TestCalculator_CalculateNewVersion(t *testing.T) {
|
|||||||
lastVersion: createVersion("1.0.0"),
|
lastVersion: createVersion("1.0.0"),
|
||||||
nextVersion: "1.0.1",
|
nextVersion: "1.0.1",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"major": []shared.AnalyzedCommit{},
|
"major": {},
|
||||||
"minor": []shared.AnalyzedCommit{},
|
"minor": {},
|
||||||
"patch": []shared.AnalyzedCommit{shared.AnalyzedCommit{}},
|
"patch": {{}},
|
||||||
"none": []shared.AnalyzedCommit{},
|
"none": {},
|
||||||
},
|
},
|
||||||
isFirst: false,
|
isFirst: false,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ func TestChangelog(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testCase: "feat",
|
testCase: "feat",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"minor": []shared.AnalyzedCommit{
|
"minor": {
|
||||||
shared.AnalyzedCommit{
|
{
|
||||||
Commit: shared.Commit{
|
Commit: shared.Commit{
|
||||||
Message: "feat(internal/changelog): my first commit",
|
Message: "feat(internal/changelog): my first commit",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
@@ -53,8 +53,8 @@ func TestChangelog(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testCase: "feat no scope",
|
testCase: "feat no scope",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"minor": []shared.AnalyzedCommit{
|
"minor": {
|
||||||
shared.AnalyzedCommit{
|
{
|
||||||
Commit: shared.Commit{
|
Commit: shared.Commit{
|
||||||
Message: "feat: my first commit",
|
Message: "feat: my first commit",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
@@ -76,8 +76,8 @@ func TestChangelog(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testCase: "feat breaking change",
|
testCase: "feat breaking change",
|
||||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
"minor": []shared.AnalyzedCommit{
|
"minor": {
|
||||||
shared.AnalyzedCommit{
|
{
|
||||||
Commit: shared.Commit{
|
Commit: shared.Commit{
|
||||||
Message: "feat(internal/changelog): my first commit",
|
Message: "feat(internal/changelog): my first commit",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
@@ -89,7 +89,7 @@ func TestChangelog(t *testing.T) {
|
|||||||
TagString: "Features",
|
TagString: "Features",
|
||||||
Print: true,
|
Print: true,
|
||||||
},
|
},
|
||||||
shared.AnalyzedCommit{
|
{
|
||||||
Commit: shared.Commit{
|
Commit: shared.Commit{
|
||||||
Message: "feat(internal/changelog): my first break: BREAKING CHANGE: change api to v2",
|
Message: "feat(internal/changelog): my first break: BREAKING CHANGE: change api to v2",
|
||||||
Author: "me",
|
Author: "me",
|
||||||
@@ -110,6 +110,81 @@ func TestChangelog(t *testing.T) {
|
|||||||
},
|
},
|
||||||
hasError: false,
|
hasError: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
testCase: "conventional commits",
|
||||||
|
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||||
|
"minor": {
|
||||||
|
{
|
||||||
|
Commit: shared.Commit{
|
||||||
|
Message: "feat!: my first break \n\nBREAKING CHANGE: hey from the change",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345669",
|
||||||
|
},
|
||||||
|
Scope: "",
|
||||||
|
ParsedMessage: "my first break",
|
||||||
|
Tag: "feat",
|
||||||
|
TagString: "Features",
|
||||||
|
Print: true,
|
||||||
|
ParsedBreakingChangeMessage: "hey from the change",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Commit: shared.Commit{
|
||||||
|
Message: "feat(internal/changelog): my first commit",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345667",
|
||||||
|
},
|
||||||
|
Scope: "internal/changelog",
|
||||||
|
ParsedMessage: "my first commit",
|
||||||
|
Tag: "feat",
|
||||||
|
TagString: "Features",
|
||||||
|
Print: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Commit: shared.Commit{
|
||||||
|
Message: "feat: my second commit",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345667",
|
||||||
|
},
|
||||||
|
Scope: "",
|
||||||
|
ParsedMessage: "my first commit",
|
||||||
|
Tag: "feat",
|
||||||
|
TagString: "Features",
|
||||||
|
Print: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Commit: shared.Commit{
|
||||||
|
Message: "feat: my new commit \n\nmy first break: BREAKING CHANGE: change api to v2",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345668",
|
||||||
|
},
|
||||||
|
Scope: "",
|
||||||
|
ParsedMessage: "my first break",
|
||||||
|
Tag: "feat",
|
||||||
|
TagString: "Features",
|
||||||
|
Print: true,
|
||||||
|
ParsedBreakingChangeMessage: "change api to v2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Commit: shared.Commit{
|
||||||
|
Message: "feat!: my next commit",
|
||||||
|
Author: "me",
|
||||||
|
Hash: "12345668",
|
||||||
|
},
|
||||||
|
Scope: "",
|
||||||
|
ParsedMessage: "",
|
||||||
|
Tag: "feat",
|
||||||
|
TagString: "Features",
|
||||||
|
Print: true,
|
||||||
|
ParsedBreakingChangeMessage: "my next commit",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
result: &shared.GeneratedChangelog{
|
||||||
|
Title: "v1.0.0 (2019-07-19)",
|
||||||
|
Content: "# v1.0.0 (2019-07-19)\n## BREAKING CHANGES\n* hey from the change \nintroduced by commit: \nmy first break ([1234566](https://commit.url))\n* change api to v2 \nintroduced by commit: \nmy first break ([1234566](https://commit.url))\n* my next commit \nintroduced by commit: \n ([1234566](https://commit.url))\n### Features\n* **`internal/changelog`** my first commit ([1234566](https://commit.url))\n* my first commit ([1234566](https://commit.url))\n",
|
||||||
|
},
|
||||||
|
hasError: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cl := changelog.New(&config.ReleaseConfig{}, []analyzer.Rule{
|
cl := changelog.New(&config.ReleaseConfig{}, []analyzer.Rule{
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import (
|
|||||||
|
|
||||||
"github.com/Nightapes/go-semantic-release/internal/ci"
|
"github.com/Nightapes/go-semantic-release/internal/ci"
|
||||||
"github.com/Nightapes/go-semantic-release/internal/gitutil"
|
"github.com/Nightapes/go-semantic-release/internal/gitutil"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/go-git/go-billy/v5/memfs"
|
"github.com/go-git/go-billy/v5/memfs"
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
"github.com/go-git/go-git/v5/plumbing/object"
|
"github.com/go-git/go-git/v5/plumbing/object"
|
||||||
"github.com/go-git/go-git/v5/storage/memory"
|
"github.com/go-git/go-git/v5/storage/memory"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCi(t *testing.T) {
|
func TestCi(t *testing.T) {
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ func (h *Hooks) runCommand(command string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd.Env = os.Environ()
|
cmd.Env = os.Environ()
|
||||||
cmd.Env = append(cmd.Env, "RELEASE_VERSION="+h.version.Next.Version.String())
|
cmd.Env = append(cmd.Env, "RELEASE_VERSION="+h.version.Next.Version.String())
|
||||||
cmdReader, err := cmd.StdoutPipe()
|
cmdReader, err := cmd.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -78,7 +78,6 @@ func (h *Hooks) runCommand(command string) error {
|
|||||||
}
|
}
|
||||||
h.printOutput(cmdErrReader, strings.Fields(cmdReplaced)[0])
|
h.printOutput(cmdErrReader, strings.Fields(cmdReplaced)[0])
|
||||||
|
|
||||||
|
|
||||||
return cmd.Run()
|
return cmd.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,14 +31,14 @@ type testReleaseStruct struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var testNewClient = []testHelperMethodStruct{
|
var testNewClient = []testHelperMethodStruct{
|
||||||
testHelperMethodStruct{config: config.GitHubProvider{
|
{config: config.GitHubProvider{
|
||||||
Repo: "foo",
|
Repo: "foo",
|
||||||
User: "bar",
|
User: "bar",
|
||||||
},
|
},
|
||||||
valid: true,
|
valid: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
testHelperMethodStruct{config: config.GitHubProvider{
|
{config: config.GitHubProvider{
|
||||||
Repo: "foo",
|
Repo: "foo",
|
||||||
User: "bar",
|
User: "bar",
|
||||||
CustomURL: "https://test.com",
|
CustomURL: "https://test.com",
|
||||||
@@ -51,7 +51,7 @@ var lastVersion, _ = semver.NewVersion("1.0.0")
|
|||||||
var newVersion, _ = semver.NewVersion("2.0.0")
|
var newVersion, _ = semver.NewVersion("2.0.0")
|
||||||
|
|
||||||
var testReleases = []testReleaseStruct{
|
var testReleases = []testReleaseStruct{
|
||||||
testReleaseStruct{
|
{
|
||||||
config: config.GitHubProvider{
|
config: config.GitHubProvider{
|
||||||
Repo: "foo",
|
Repo: "foo",
|
||||||
User: "bar",
|
User: "bar",
|
||||||
@@ -75,7 +75,7 @@ var testReleases = []testReleaseStruct{
|
|||||||
requestResponseCode: 200,
|
requestResponseCode: 200,
|
||||||
valid: true,
|
valid: true,
|
||||||
},
|
},
|
||||||
testReleaseStruct{
|
{
|
||||||
config: config.GitHubProvider{
|
config: config.GitHubProvider{
|
||||||
Repo: "foo",
|
Repo: "foo",
|
||||||
User: "bar",
|
User: "bar",
|
||||||
|
|||||||
@@ -148,7 +148,6 @@ func (g *Client) uploadAssets(assets *assets.Set) error {
|
|||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
|
|
||||||
result, err := g.uploadFile(asset.GetName(), file)
|
result, err := g.uploadFile(asset.GetName(), file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not upload asset %s: %s", file.Name(), err.Error())
|
return fmt.Errorf("could not upload asset %s: %s", file.Name(), err.Error())
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ func TestUploadAssets(t *testing.T) {
|
|||||||
valid: true,
|
valid: true,
|
||||||
testDir: os.TempDir(),
|
testDir: os.TempDir(),
|
||||||
assets: []config.Asset{
|
assets: []config.Asset{
|
||||||
config.Asset{
|
{
|
||||||
Name: filepath.Base(file.Name()),
|
Name: filepath.Base(file.Name()),
|
||||||
Compress: false,
|
Compress: false,
|
||||||
},
|
},
|
||||||
@@ -258,7 +258,7 @@ func TestUploadAssets(t *testing.T) {
|
|||||||
valid: false,
|
valid: false,
|
||||||
testDir: os.TempDir(),
|
testDir: os.TempDir(),
|
||||||
assets: []config.Asset{
|
assets: []config.Asset{
|
||||||
config.Asset{
|
{
|
||||||
Name: filepath.Base(file.Name()),
|
Name: filepath.Base(file.Name()),
|
||||||
Compress: false,
|
Compress: false,
|
||||||
},
|
},
|
||||||
@@ -277,7 +277,7 @@ func TestUploadAssets(t *testing.T) {
|
|||||||
valid: false,
|
valid: false,
|
||||||
testDir: os.TempDir(),
|
testDir: os.TempDir(),
|
||||||
assets: []config.Asset{
|
assets: []config.Asset{
|
||||||
config.Asset{
|
{
|
||||||
Name: filepath.Base(file.Name()),
|
Name: filepath.Base(file.Name()),
|
||||||
Compress: false,
|
Compress: false,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ type testDoubleToken struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var testDoubles = []testDoubleToken{
|
var testDoubles = []testDoubleToken{
|
||||||
testDoubleToken{providerName: "test0", token: "foo", valid: true},
|
{providerName: "test0", token: "foo", valid: true},
|
||||||
testDoubleToken{providerName: "test1", token: "", valid: false},
|
{providerName: "test1", token: "", valid: false},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetAccessToken(t *testing.T) {
|
func TestGetAccessToken(t *testing.T) {
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ github:
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Assets: []config.Asset{
|
Assets: []config.Asset{
|
||||||
config.Asset{
|
{
|
||||||
Name: "./build/go-semantic-release",
|
Name: "./build/go-semantic-release",
|
||||||
Compress: false}},
|
Compress: false}},
|
||||||
ReleaseTitle: "go-semantic-release release",
|
ReleaseTitle: "go-semantic-release release",
|
||||||
|
|||||||
Reference in New Issue
Block a user