From 7d74abd67765922a5ff9710852ada8bbe78cbd6d Mon Sep 17 00:00:00 2001 From: Sheldon Hull Date: Thu, 22 Jul 2021 18:07:18 -0500 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=9A=9A=20adjust=20module=20na?= =?UTF-8?q?ming=20to=20support=20go=20install?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 9 ++++++++- .golangci.yml | 26 ++++++++++++++++++++++++++ Makefile | 12 +++++++++++- README.md | 6 +++--- cmd/git-sv/config.go | 6 +++--- cmd/git-sv/config_test.go | 3 ++- cmd/git-sv/handlers.go | 5 ++--- cmd/git-sv/main.go | 3 ++- go.mod | 2 +- go.sum | 11 ----------- 10 files changed, 58 insertions(+), 25 deletions(-) create mode 100644 .golangci.yml diff --git a/.gitignore b/.gitignore index 3b860b3..b3eda77 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,11 @@ bin/ # Output of the go coverage tool, specifically when used with LiteIDE *.out -*.sample \ No newline at end of file +*.sample + +# Additional generated artifacts +artifacts/ + +# Mac metadata + +.DS_Store diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..2d0a9ae --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,26 @@ +linters: + # disable-all: true + # enable: + # - megacheck + # - govet + enable-all: true + disable: + - scopelint + - paralleltest + - staticcheck + - noctx + - wsl + - lll + - forbidigo + # - prealloc + # presets: + # - bugs + # - unused + + # bugs|comment|complexity|error|format|import|metalinter|module|performance|sql|style|test|unused + fast: true + +run: + skip-dirs: + - build + - artifacts diff --git a/Makefile b/Makefile index 32e63b5..5e014bc 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,16 @@ build: test @echo $(ECHOFLAGS) "$(OK_COLOR)==> Building binary ($(BUILDOS)/$(BUILDARCH)/$(BIN))...$(NO_COLOR)" @$(BUILDENVS) go build -v $(BUILDFLAGS) -o bin/$(BUILDOS)_$(BUILDARCH)/$(BIN) ./cmd/git-sv +## list: run golangci-lint without autofix +lint: + @echo $(ECHOFLAGS) "$(OK_COLOR)==> Running golangci-lint...$(NO_COLOR)" + @golangci-lint run ./... --config .golangci.yml + +## autofix: run golangci-lint with autofix enabled +autofix: + @echo $(ECHOFLAGS) "$(OK_COLOR)==> Running golangci-lint...$(NO_COLOR)" + @golangci-lint run ./... --config .golangci.yml --fix + ## test: run unit tests test: @echo $(ECHOFLAGS) "$(OK_COLOR)==> Running tests...$(NO_COLOR)" @@ -69,7 +79,7 @@ endif ## release-all: prepare linux, darwin and windows binary for release (requires sv4git) release-all: @rm -rf bin - + VERSION=$(shell git sv nv) BUILDOS=linux make release VERSION=$(shell git sv nv) BUILDOS=darwin make release VERSION=$(shell git sv nv) COMPRESS_TYPE=zip BUILDOS=windows make release diff --git a/README.md b/README.md index 8c6390c..18ca218 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ versioning: # versioning bump - refactor - style - test - # When type is not present on update rules and is unknown (not mapped on commit message types); + # When type is not present on update rules and is unknown (not mapped on commit message types); # if ignore-unknown=false bump patch, if ignore-unknown=true do not bump version ignore-unknown: false @@ -119,7 +119,7 @@ commit-message: scope: # Define supported scopes, if blank, scope will not be validated, if not, only scope listed will be valid. # Don't forget to add "" on your list if you need to define scopes and keep it optional. - values: [] + values: [] footer: issue: # Use "issue: {}" if you wish to disable issue footer. key: jira # Name used to define an issue on footer metadata. @@ -212,7 +212,7 @@ SHA1=$3 git sv vcm --path "$(pwd)" --file "$COMMIT_MSG_FILE" --source "$COMMIT_SOURCE" ``` -**Tip**: you can configure a directory as your global git templates using the command below: +**Tip**: you can configure a directory as your global git templates using the command below: ```bash git config --global init.templatedir '' diff --git a/cmd/git-sv/config.go b/cmd/git-sv/config.go index 6bcd650..dfb00dc 100644 --- a/cmd/git-sv/config.go +++ b/cmd/git-sv/config.go @@ -8,7 +8,8 @@ import ( "os/exec" "reflect" "strings" - "sv4git/sv" + + "github.com/bvieira/sv4git/sv" "github.com/imdario/mergo" "github.com/kelseyhightower/envconfig" @@ -103,8 +104,7 @@ func merge(dst *Config, src Config) error { return err } -type mergeTransformer struct { -} +type mergeTransformer struct{} func (t *mergeTransformer) Transformer(typ reflect.Type) func(dst, src reflect.Value) error { if typ.Kind() == reflect.Slice { diff --git a/cmd/git-sv/config_test.go b/cmd/git-sv/config_test.go index 33fda71..191e445 100644 --- a/cmd/git-sv/config_test.go +++ b/cmd/git-sv/config_test.go @@ -2,8 +2,9 @@ package main import ( "reflect" - "sv4git/sv" "testing" + + "github.com/bvieira/sv4git/sv" ) func Test_merge(t *testing.T) { diff --git a/cmd/git-sv/handlers.go b/cmd/git-sv/handlers.go index a93a00b..cc3da8e 100644 --- a/cmd/git-sv/handlers.go +++ b/cmd/git-sv/handlers.go @@ -8,9 +8,10 @@ import ( "path/filepath" "sort" "strings" - "sv4git/sv" "time" + "github.com/bvieira/sv4git/sv" + "github.com/Masterminds/semver/v3" "github.com/urfave/cli/v2" "gopkg.in/yaml.v3" @@ -267,7 +268,6 @@ func tagHandler(git sv.Git, semverProcessor sv.SemVerCommitsProcessor) func(c *c func commitHandler(cfg Config, git sv.Git, messageProcessor sv.MessageProcessor) func(c *cli.Context) error { return func(c *cli.Context) error { - ctype, err := promptType(cfg.CommitMessage.Types) if err != nil { return err @@ -333,7 +333,6 @@ func commitHandler(cfg Config, git sv.Git, messageProcessor sv.MessageProcessor) func changelogHandler(git sv.Git, semverProcessor sv.SemVerCommitsProcessor, rnProcessor sv.ReleaseNoteProcessor, formatter sv.OutputFormatter) func(c *cli.Context) error { return func(c *cli.Context) error { - tags, err := git.Tags() if err != nil { return err diff --git a/cmd/git-sv/main.go b/cmd/git-sv/main.go index ada9e6f..21edcee 100644 --- a/cmd/git-sv/main.go +++ b/cmd/git-sv/main.go @@ -4,7 +4,8 @@ import ( "log" "os" "path/filepath" - "sv4git/sv" + + "github.com/bvieira/sv4git/sv" "github.com/urfave/cli/v2" ) diff --git a/go.mod b/go.mod index 3f98cf5..357b37e 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module sv4git +module github.com/bvieira/sv4git go 1.15 diff --git a/go.sum b/go.sum index d0a91e1..5f045cc 100644 --- a/go.sum +++ b/go.sum @@ -7,7 +7,6 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5O github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -18,47 +17,37 @@ github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a h1:FaWFmfWdAUKbSCtOU github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a/go.mod h1:UJSiEoRfvx3hP73CvoARgeLjaIOjybY9vj8PUPPFGeU= github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8= github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a h1:weJVJJRzAJBFRlAiJQROKQs8oC9vOxvm4rZmBBk0ONw= github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= github.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+LVb8= github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= github.com/manifoldco/promptui v0.8.0 h1:R95mMF+McvXZQ7j1g8ucVZE1gLP3Sv6j9vlF9kyRqQo= github.com/manifoldco/promptui v0.8.0/go.mod h1:n4zTdgP0vr0S3w7/O/g98U+e0gwLScEXGwov2nIKuGQ= -github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= -golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b h1:MQE+LT/ABUuuvEZ+YQAMSXindAdUh7slEmAkup74op4= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=