diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..3e16b8c7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,105 @@ +name: ci + +on: + pull_request: + types: ["opened", "synchronize"] + paths-ignore: + - "README.md" + push: + branches: + - master + paths-ignore: + - "README.md" + +env: + GO_VERSION: "1.24" + GOLANGCI_VERSION: "v1.64.8" + +jobs: + tests: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Run tests + run: make test + + - name: Install goveralls + run: | + go install github.com/mattn/goveralls@latest + echo $GOPATH + ls -lash $GOPATH + which goveralls + working-directory: /tmp + + - name: Send coverage + run: goveralls -coverprofile=cover.out -service=github + env: + COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + lint: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: ${{ env.GOLANGCI_VERSION }} + + docker-image-tests: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Run tests + run: make build + + - name: Test docker image + run: | + docker build -t git-chglog:ci-build . + docker run -v ${GITHUB_WORKSPACE}:/workdir -w /workdir git-chglog:ci-build > ${GITHUB_WORKSPACE}/ci-build.md + head ${GITHUB_WORKSPACE}/ci-build.md + + goreleaser-test: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4 + with: + version: latest + args: release --clean --skip=publish --snapshot diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 49f5fde0..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: lint - -on: - pull_request: - types: ['opened', 'synchronize'] - push: - branches: - - master -jobs: - golangci: - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: golangci-lint - uses: golangci/golangci-lint-action@v2 - with: - version: v1.38 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..f9386129 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,34 @@ +name: publish + +on: + push: + branches: + - master + +env: + GO_VERSION: "1.24" + DOCKER_REGISTRY: "quay.io" + +jobs: + docker: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Login to Docker Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ secrets.QUAY_IO_USER }} + password: ${{ secrets.QUAY_IO_TOKEN }} + + - name: Build and Push docker image + run: DOCKER_TAG=edge make docker push diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2cc15f77..8236dec5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,26 +1,39 @@ -name: goreleaser +name: release on: push: tags: - - '*' + - "*" + +env: + GO_VERSION: "1.24" + DOCKER_REGISTRY: "quay.io" jobs: goreleaser: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: - go-version: 1.16 + go-version: ${{ env.GO_VERSION }} + + - name: Login to Docker Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ secrets.QUAY_IO_USER }} + password: ${{ secrets.QUAY_IO_TOKEN }} + - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 + uses: goreleaser/goreleaser-action@v4 with: version: latest - args: release --rm-dist + args: release --clean env: GITHUB_TOKEN: ${{ secrets.GORELEASER_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 3327c1ab..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: tests - -on: - pull_request: - types: ['opened', 'synchronize'] - paths-ignore: - - 'README.md' - push: - branches: - - master - paths-ignore: - - 'README.md' -jobs: - unit: - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.16 - - name: Run tests - run: | - make test - - name: Install goveralls - env: - GO111MODULE: off - run: go get github.com/mattn/goveralls - - name: Send coverage - env: - COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: goveralls -coverprofile=cover.out -service=github diff --git a/.gitignore b/.gitignore index c331ce69..8ce7945e 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,9 @@ Icon *.iml .idea +# vscode IDE +.vscode + # Files that might appear in the root of a volume .DocumentRevisions-V100 .fseventsd diff --git a/.golangci.yml b/.golangci.yml index c409770d..4e3fdd88 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,22 +1,10 @@ # https://golangci-lint.run/usage/configuration/ run: timeout: 10m - deadline: 5m tests: true -output: - format: tab - linters-settings: - govet: - # report about shadowed variables - check-shadowing: true - - golint: - # minimal confidence for issues, default is 0.8 - min-confidence: 0.8 - gofmt: # simplify code: gofmt with `-s` option, true by default simplify: true @@ -30,10 +18,6 @@ linters-settings: # minimal code complexity to report, 30 by default (but we recommend 10-20) min-complexity: 10 - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true - dupl: # tokens count to trigger issue, 150 by default threshold: 100 @@ -48,13 +32,6 @@ linters-settings: # tab width in spaces. Default to 1. tab-width: 1 - unused: - # treat code as a program (not a library) and report unused exported identifiers; default is false. - # XXX: if you enable this setting, unused will report a lot of false-positives in text editors: - # if it's called for subdir of a project it can't find funcs usages. All text editor integrations - # with golangci-lint call it on a directory with the changed file. - check-exported: false - unparam: # Inspect exported functions, default is false. Set to true if no external program/library imports your code. # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: @@ -76,38 +53,24 @@ linters-settings: range-loops: true # Report preallocation suggestions on range loops, true by default for-loops: false # Report preallocation suggestions on for loops, false by default - gocritic: - # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint` run to see all tags and checks. - # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags". - enabled-tags: - - performance - - settings: # settings passed to gocritic - captLocal: # must be valid enabled check name - paramsOnly: true - rangeValCopy: - sizeThreshold: 32 - misspell: locale: US linters: enable: - - megacheck - - govet + - gosimple + - staticcheck + - unused - gocyclo - - gocritic - - interfacer - goconst - goimports - gofmt # We enable this as well as goimports for its simplify mode. - prealloc - - golint - unconvert - misspell - nakedret - dupl - - depguard + #- depguard TODO fix later presets: - bugs @@ -124,21 +87,9 @@ issues: - errcheck - dupl - gosec - - scopelint - unparam - - # These are performance optimisations rather than style issues per se. - # They warn when function arguments or range values copy a lot of memory - # rather than using a pointer. - - text: "(hugeParam|rangeValCopy):" - linters: - - gocritic - - # Independently from option `exclude` we use default exclude patterns, - # it can be disabled by this option. To list all - # excluded by default patterns execute `golangci-lint run --help`. - # Default value for this option is true. - exclude-use-default: false + - testifylint + - depguard # Show only new issues: if there are unstaged changes or untracked files, # only those changes are analyzed, else only changes in HEAD~ are analyzed. @@ -148,8 +99,5 @@ issues: # Default is false. new: false - # Maximum issues count per one linter. Set to 0 to disable. Default is 50. - max-per-linter: 0 - # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. max-same-issues: 0 diff --git a/.goreleaser.yml b/.goreleaser.yml index 0272d395..9b4766ad 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,3 +1,5 @@ +version: 2 + # This is an example .goreleaser.yml file with some sane defaults. # Make sure to check the documentation at http://goreleaser.com project_name: git-chglog @@ -27,19 +29,24 @@ archives: format: zip checksum: - name_template: 'checksums.txt' + name_template: "checksums.txt" changelog: sort: desc filters: exclude: - - '^Merge' + - "^Merge" snapshot: name_template: "{{ .Tag }}-next" +dockers: + - image_templates: + - "quay.io/git-chglog/git-chglog:{{ .RawVersion }}" + - "quay.io/git-chglog/git-chglog:latest" + brews: - - tap: + - repository: owner: git-chglog name: homebrew-git-chglog homepage: "https://godoc.org/github.com/git-chglog/git-chglog" @@ -47,4 +54,4 @@ brews: test: | system "#{bin}/git-chglog --help" install: | - bin.install "git-chglog" \ No newline at end of file + bin.install "git-chglog" diff --git a/CHANGELOG.md b/CHANGELOG.md index e8ea0194..d25fac2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,97 @@ ## [Unreleased] + +## [v0.15.4] - 2023-02-15 +### Bug Fixes +- release process ([#231](https://github.com/git-chglog/git-chglog/issues/231)) +- **ci:** add integration test with docker image ([#226](https://github.com/git-chglog/git-chglog/issues/226)) +- **deps:** update module github.com/urfave/cli/v2 to v2.24.3 ([#227](https://github.com/git-chglog/git-chglog/issues/227)) +- **deps:** update module github.com/fatih/color to v1.14.1 ([#224](https://github.com/git-chglog/git-chglog/issues/224)) +- **deps:** update all non-major dependencies ([#223](https://github.com/git-chglog/git-chglog/issues/223)) + +### Chores +- new release due to shecksum mismatch. Closes [#232](https://github.com/git-chglog/git-chglog/issues/232) +- update changelog for v0.15.3 +- update changelog for v0.15.3 +- bump docker/login-action to v2. Closes [#206](https://github.com/git-chglog/git-chglog/issues/206) +- bump goreleaser/goreleaser-action to v4. Closes [#208](https://github.com/git-chglog/git-chglog/issues/208) + + + +## [v0.15.2] - 2023-01-22 +### Bug Fixes +- typo in readme ([#196](https://github.com/git-chglog/git-chglog/issues/196)) +- **deps:** update module gopkg.in/yaml.v2 to v3 ([#221](https://github.com/git-chglog/git-chglog/issues/221)) + +### Chores +- update changelog for v0.15.2 +- update changelog for v0.15.2 +- update Go install instructions ([#205](https://github.com/git-chglog/git-chglog/issues/205)) +- bump golang to 1.19 ([#218](https://github.com/git-chglog/git-chglog/issues/218)) +- **deps:** update all non-major dependencies ([#220](https://github.com/git-chglog/git-chglog/issues/220)) + + + +## [v0.15.1] - 2021-12-14 +### Bug Fixes +- **deps:** update all non-major dependencies ([#179](https://github.com/git-chglog/git-chglog/issues/179)) +- **deps:** update module github.com/andygrunwald/go-jira to v1.14.0 ([#167](https://github.com/git-chglog/git-chglog/issues/167)) +- **deps:** update module github.com/alecaivazis/survey/v2 to v2.2.16 ([#165](https://github.com/git-chglog/git-chglog/issues/165)) +- **deps:** update module github.com/alecaivazis/survey/v2 to v2.2.15 ([#163](https://github.com/git-chglog/git-chglog/issues/163)) + +### Chores +- update changelog for v0.15.1 +- ignore .vscode +- **deps:** update all non-major dependencies docker tags ([#168](https://github.com/git-chglog/git-chglog/issues/168)) + + + +## [v0.15.0] - 2021-07-09 +### Bug Fixes +- **deps:** update module github.com/alecaivazis/survey/v2 to v2.2.14 ([#158](https://github.com/git-chglog/git-chglog/issues/158)) +- **deps:** update module github.com/alecaivazis/survey/v2 to v2.2.13 ([#156](https://github.com/git-chglog/git-chglog/issues/156)) +- **deps:** update module github.com/fatih/color to v1.12.0 ([#150](https://github.com/git-chglog/git-chglog/issues/150)) +- **deps:** update module github.com/fatih/color to v1.11.0 ([#149](https://github.com/git-chglog/git-chglog/issues/149)) +- **deps:** update module github.com/alecaivazis/survey/v2 to v2.2.12 ([#147](https://github.com/git-chglog/git-chglog/issues/147)) + +### Chores +- update changelog for v0.15.0 +- **deps:** update alpine docker tag to v3.14.0 ([#153](https://github.com/git-chglog/git-chglog/issues/153)) + +### Features +- Automatic link for gitlab merge requests ([#160](https://github.com/git-chglog/git-chglog/issues/160)) + + + +## [v0.14.2] - 2021-04-16 +### Bug Fixes +- add CommitGroupTitleOrder back to Options ([#143](https://github.com/git-chglog/git-chglog/issues/143)) + +### Chores +- update changelog for v0.14.2 +- **deps:** update alpine docker tag to v3.13.5 ([#144](https://github.com/git-chglog/git-chglog/issues/144)) + + + +## [v0.14.1] - 2021-04-13 +### Bug Fixes +- **template:** address regression in string functions for template engine ([#142](https://github.com/git-chglog/git-chglog/issues/142)) + +### Chores +- update changelog for v0.14.1 +- add docker target to Makefile ([#138](https://github.com/git-chglog/git-chglog/issues/138)) +- add make release target ([#130](https://github.com/git-chglog/git-chglog/issues/130)) +- **deps:** update alpine docker tag to v3.13.4 ([#136](https://github.com/git-chglog/git-chglog/issues/136)) + +### Features +- add docker image on release and master ([#135](https://github.com/git-chglog/git-chglog/issues/135)) + + ## [v0.14.0] - 2021-03-28 ### Chores +- update changelog for v0.14.0 - **CHANGELOG:** regenerate CHANGELOG with type-scope and KAC template ([#129](https://github.com/git-chglog/git-chglog/issues/129)) ### Features @@ -342,7 +430,13 @@ - First implement -[Unreleased]: https://github.com/git-chglog/git-chglog/compare/v0.14.0...HEAD +[Unreleased]: https://github.com/git-chglog/git-chglog/compare/v0.15.4...HEAD +[v0.15.4]: https://github.com/git-chglog/git-chglog/compare/v0.15.2...v0.15.4 +[v0.15.2]: https://github.com/git-chglog/git-chglog/compare/v0.15.1...v0.15.2 +[v0.15.1]: https://github.com/git-chglog/git-chglog/compare/v0.15.0...v0.15.1 +[v0.15.0]: https://github.com/git-chglog/git-chglog/compare/v0.14.2...v0.15.0 +[v0.14.2]: https://github.com/git-chglog/git-chglog/compare/v0.14.1...v0.14.2 +[v0.14.1]: https://github.com/git-chglog/git-chglog/compare/v0.14.0...v0.14.1 [v0.14.0]: https://github.com/git-chglog/git-chglog/compare/v0.13.0...v0.14.0 [v0.13.0]: https://github.com/git-chglog/git-chglog/compare/v0.12.0...v0.13.0 [v0.12.0]: https://github.com/git-chglog/git-chglog/compare/v0.11.2...v0.12.0 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..1df3acfd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM alpine + +RUN apk add --no-cache git && \ + mkdir /workdir && \ + git config --global --add safe.directory /workdir + +COPY git-chglog /usr/local/bin/git-chglog + +WORKDIR /workdir +RUN chmod +x /usr/local/bin/git-chglog + +ENTRYPOINT [ "/usr/local/bin/git-chglog" ] \ No newline at end of file diff --git a/Makefile b/Makefile index cc5b6c0b..8c09f6fd 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,108 @@ -VERSION?=$$(git describe --tags --always) +# Build variables +VERSION ?= $(shell git describe --tags --always) -LDFLAGS="-X main.version=$(VERSION)" +# Go variables +GO ?= go +GOOS ?= $(shell $(GO) env GOOS) +GOARCH ?= $(shell $(GO) env GOARCH) +GOHOST ?= GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO) + +LDFLAGS ?= "-X main.version=$(VERSION)" + +# Docker variables +DEFAULT_TAG ?= $(shell echo "$(VERSION)" | tr -d 'v') +DOCKER_IMAGE := quay.io/git-chglog/git-chglog +DOCKER_TAG ?= $(DEFAULT_TAG) + +.PHONY: all +all: help + +############### +##@ Development .PHONY: clean -clean: +clean: ## Clean workspace + @ $(MAKE) --no-print-directory log-$@ rm -rf ./dist/ rm -rf ./git-chglog rm -rf $(GOPATH)/bin/git-chglog rm -rf cover.out -.PHONY: build -build: - go build -ldflags=$(LDFLAGS) -o git-chglog ./cmd/git-chglog - .PHONY: test -test: - go test -covermode atomic -coverprofile cover.out -v ./... - -.PHONY: install -install: - go install ./cmd/git-chglog - -.PHONY: changelog -changelog: build - ./git-chglog --next-tag $(VERSION) -o CHANGELOG.md +test: ## Run tests + @ $(MAKE) --no-print-directory log-$@ + $(GOHOST) test -covermode atomic -coverprofile cover.out -v ./... .PHONY: lint -lint: - @golangci-lint run +lint: ## Run linters + @ $(MAKE) --no-print-directory log-$@ + golangci-lint run + +######### +##@ Build + +.PHONY: build +build: ## Build git-chglog + @ $(MAKE) --no-print-directory log-$@ + CGO_ENABLED=0 $(GOHOST) build -ldflags=$(LDFLAGS) -o git-chglog ./cmd/git-chglog + +.PHONY: install +install: ## Install git-chglog + @ $(MAKE) --no-print-directory log-$@ + $(GOHOST) install ./cmd/git-chglog + +.PHONY: docker +docker: build ## Build Docker image + @ $(MAKE) --no-print-directory log-$@ + docker build --pull --tag $(DOCKER_IMAGE):$(DOCKER_TAG) . + +.PHONY: push +push: ## Push Docker image + @ $(MAKE) --no-print-directory log-$@ + docker push $(DOCKER_IMAGE):$(DOCKER_TAG) + +########### +##@ Release + +.PHONY: changelog +changelog: build ## Generate changelog + @ $(MAKE) --no-print-directory log-$@ + ./git-chglog --next-tag $(VERSION) -o CHANGELOG.md + +.PHONY: release +release: changelog ## Release a new tag + @ $(MAKE) --no-print-directory log-$@ + git add CHANGELOG.md + git commit -m "chore: update changelog for $(VERSION)" + git tag $(VERSION) + git push origin master $(VERSION) + +######## +##@ Help + +.PHONY: help +help: ## Display this help + @awk \ + -v "col=\033[36m" -v "nocol=\033[0m" \ + ' \ + BEGIN { \ + FS = ":.*##" ; \ + printf "Usage:\n make %s%s\n", col, nocol \ + } \ + /^[a-zA-Z_-]+:.*?##/ { \ + printf " %s%-12s%s %s\n", col, $$1, nocol, $$2 \ + } \ + /^##@/ { \ + printf "\n%s%s%s\n", nocol, substr($$0, 5), nocol \ + } \ + ' $(MAKEFILE_LIST) + +log-%: + @grep -h -E '^$*:.*?## .*$$' $(MAKEFILE_LIST) | \ + awk \ + 'BEGIN { \ + FS = ":.*?## " \ + }; \ + { \ + printf "\033[36m==> %s\033[0m\n", $$2 \ + }' diff --git a/README.md b/README.md index fa6cab54..f053839f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ [![godoc.org](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/git-chglog/git-chglog) [![Actions Status](https://github.com/git-chglog/git-chglog/workflows/tests/badge.svg)](https://github.com/git-chglog/git-chglog/actions) -[![AppVeyor](https://img.shields.io/appveyor/ci/tsuyoshiwada/git-chglog/master.svg?style=flat-square)](https://ci.appveyor.com/project/tsuyoshiwada/git-chglog/branch/master) [![Coverage Status](https://img.shields.io/coveralls/github/git-chglog/git-chglog.svg?style=flat-square)](https://coveralls.io/github/git-chglog/git-chglog?branch=master) [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/git-chglog/git-chglog/blob/master/LICENSE) @@ -23,6 +22,7 @@ - [Scoop (for Windows users)](#scoop-for-windows-users) - [asdf](#asdf) - [Go users](#go-users) + - [Docker](#docker) - [Test Installation](#test-installation) - [Quick Start](#quick-start) - [CLI Usage](#cli-usage) @@ -33,6 +33,7 @@ - [`template`](#template) - [`info`](#info) - [`options`](#options) + - [`options.sort`](#optionssort) - [`options.commits`](#optionscommits) - [`options.commit_groups`](#optionscommit_groups) - [`options.header`](#optionsheader) @@ -51,8 +52,9 @@ - [TODO](#todo) - [Thanks](#thanks) - [Contributing](#contributing) - - [Development](#development) - - [Feedback](#feedback) + - [Development](#development) + - [Release Process](#release-process) + - [Feedback](#feedback) - [CHANGELOG](#changelog) - [Related Projects](#related-projects) - [License](#license) @@ -110,9 +112,19 @@ asdf install git-chglog latest #### Go users ```bash -go get -u github.com/git-chglog/git-chglog/cmd/git-chglog +go install github.com/git-chglog/git-chglog/cmd/git-chglog@latest ``` +### [Docker](https://www.docker.com/) +The compiled docker images are maintained on [quay.io](https://quay.io/repository/git-chglog/git-chglog). +We maintain the following tags: +- `edge`: Image that is build from the current `HEAD` of the main line branch. +- `latest`: Image that is built from the [latest released version](https://github.com/git-chglog/git-chglog/releases) +- `x.y.y` (versions): Images that are build from the tagged versions within Github. +```bash +docker pull quay.io/git-chglog/git-chglog:latest +docker run -v "$PWD":/workdir quay.io/git-chglog/git-chglog --version +``` --- If you are using another platform, you can download a binary from the [releases page] @@ -430,9 +442,22 @@ Options to detect notes contained in commit bodies. ## Templates -The `git-chglog` template uses the `text/template` package and enhanced templating functions provided by [Sprig](http://masterminds.github.io/sprig). For basic usage please refer to the following. +The `git-chglog` template uses the `text/template` package and enhanced templating functions provided by [Sprig]. For basic usage please refer to the following. -> [text/template](https://golang.org/pkg/text/template/) +- [text/template](https://golang.org/pkg/text/template/) +- [Sprig] + +We have implemented the following custom template functions. These override functions provided by [Sprig]. + +| Name | Signature | Description | +| :----------- | :-------------------------------------------- | :---------------------------------------------------------------------------- | +| `contains` | `func(s, substr string) bool` | Reports whether `substr` is within `s` using `strings.Contains` | +| `datetime` | `func(layout string, input time.Time) string` | Generate a formatted Date string based on layout | +| `hasPrefix` | `func(s, prefix string) bool` | Tests whether the string `s` begins with `prefix` using `strings.HasPrefix` | +| `hasSuffix` | `func(s, suffix string) bool` | Tests whether the string `s` ends with `suffix`. using `strings.HasPrefix` | +| `indent` | `func(s string, n int) string` | Indent all lines of `s` by `n` spaces | +| `replace` | `func(s, old, new string, n int) string` | Replace `old` with `new` within string `s`, `n` times using `strings.Replace` | +| `upperFirst` | `func(s string) string` | Upper case the first character of a string | If you are not satisfied with the prepared template please try customizing one. @@ -657,11 +682,11 @@ Within a `Commit`, the following Jira data can be used in template: ## Contributing -We alway welcome your contributions :clap: +We always welcome your contributions :clap: -### Development +## Development -1. Use Golang version `>= 1.16` +1. Use Golang version `>= 1.24` 1. Fork (https://github.com/git-chglog/git-chglog) :tada: 1. Create a feature branch :coffee: 1. Run test suite with the `$ make test` command and confirm that it passes :zap: @@ -673,7 +698,24 @@ We alway welcome your contributions :clap: Bugs, feature requests and comments are more than welcome in the [issues]. -### Feedback +## Release Process + +There is a `release` target within the Makefile that wraps up the steps to +release a new version. + +> NOTE: Pass the `VERSION` variable when running the command to properly set +> the tag version for the release. + +```bash +$ VERSION=vX.Y.Z make release +# EXAMPLE: +$ VERSION=v0.11.3 make release +``` + +Once the `tag` has been pushed, the `goreleaser` github action will take care +of the rest. + +## Feedback I would like to make `git-chglog` a better tool. The goal is to be able to use in various projects. @@ -703,3 +745,4 @@ See [CHANGELOG.md](./CHANGELOG.md) [golangci-lint]: https://golangci-lint.run/usage/install/#local-installation [issues]: https://github.com/git-chglog/git-chglog/issues [git-chglog/artwork]: https://github.com/git-chglog/artwork +[Sprig]: http://masterminds.github.io/sprig diff --git a/chglog.go b/chglog.go index 541f577a..fc5cf9e3 100644 --- a/chglog.go +++ b/chglog.go @@ -132,10 +132,11 @@ func NewGenerator(logger *Logger, config *Config) *Generator { // Generate gets the commit based on the specified tag `query` and writes the result to `io.Writer` // // tag `query` can be specified with the following rule -// .. - Commit contained in `` tags from `` (e.g. `1.0.0..2.0.0`) -// .. - Commit from the `` to the latest tag (e.g. `1.0.0..`) -// .. - Commit from the oldest tag to `` (e.g. `..1.0.0`) -// - Commit contained in `` (e.g. `1.0.0`) +// +// .. - Commit contained in `` tags from `` (e.g. `1.0.0..2.0.0`) +// .. - Commit from the `` to the latest tag (e.g. `1.0.0..`) +// .. - Commit from the oldest tag to `` (e.g. `..1.0.0`) +// - Commit contained in `` (e.g. `1.0.0`) func (gen *Generator) Generate(w io.Writer, query string) error { back, err := gen.workdir() if err != nil { @@ -340,6 +341,13 @@ func (gen *Generator) render(w io.Writer, unreleased *Unreleased, versions []*Ve pad := strings.Repeat(" ", n) return pad + strings.ReplaceAll(s, "\n", "\n"+pad) }, + // While Sprig provides these functions, they change the standard input + // order which leads to a regression. For an example see: + // https://github.com/Masterminds/sprig/blob/master/functions.go#L149 + "contains": strings.Contains, + "hasPrefix": strings.HasPrefix, + "hasSuffix": strings.HasSuffix, + "replace": strings.Replace, } fname := filepath.Base(gen.config.Template) diff --git a/cmd/git-chglog/config.go b/cmd/git-chglog/config.go index 98e22fbd..abfe82e8 100644 --- a/cmd/git-chglog/config.go +++ b/cmd/git-chglog/config.go @@ -316,6 +316,7 @@ func (config *Config) Convert(ctx *CLIContext) *chglog.Config { CommitGroupBy: opts.CommitGroups.GroupBy, CommitGroupSortBy: opts.CommitGroups.SortBy, CommitGroupTitleMaps: opts.CommitGroups.TitleMaps, + CommitGroupTitleOrder: opts.CommitGroups.TitleOrder, HeaderPattern: opts.Header.Pattern, HeaderPatternMaps: opts.Header.PatternMaps, IssuePrefix: opts.Issues.Prefix, diff --git a/cmd/git-chglog/config_loader.go b/cmd/git-chglog/config_loader.go index d49eb779..2600dfec 100644 --- a/cmd/git-chglog/config_loader.go +++ b/cmd/git-chglog/config_loader.go @@ -1,7 +1,7 @@ package main import ( - "io/ioutil" + "os" "path/filepath" "gopkg.in/yaml.v2" @@ -22,7 +22,7 @@ func NewConfigLoader() ConfigLoader { func (loader *configLoaderImpl) Load(path string) (*Config, error) { fp := filepath.Clean(path) - bytes, err := ioutil.ReadFile(fp) + bytes, err := os.ReadFile(fp) if err != nil { return nil, err } diff --git a/cmd/git-chglog/fs.go b/cmd/git-chglog/fs.go index 1617e0bb..f2c547b8 100644 --- a/cmd/git-chglog/fs.go +++ b/cmd/git-chglog/fs.go @@ -2,7 +2,6 @@ package main import ( "io" - "io/ioutil" "os" ) @@ -35,15 +34,18 @@ func (*osFileSystem) Exists(path string) bool { func (*osFileSystem) MkdirP(path string) error { if _, err := os.Stat(path); os.IsNotExist(err) { + //nolint:gosec return os.MkdirAll(path, os.ModePerm) } return nil } func (*osFileSystem) Create(name string) (File, error) { + //nolint: gosec return os.Create(name) } func (*osFileSystem) WriteFile(path string, content []byte) error { - return ioutil.WriteFile(path, content, os.ModePerm) + //nolint:gosec + return os.WriteFile(path, content, os.ModePerm) } diff --git a/commit_extractor.go b/commit_extractor.go index c5921ca7..1c4fc2ad 100644 --- a/commit_extractor.go +++ b/commit_extractor.go @@ -119,6 +119,7 @@ func (e *commitExtractor) commitGroupTitle(commit *Commit) (string, string) { if t, ok := e.opts.CommitGroupTitleMaps[v]; ok { ttl = t } else { + //nolint:staticcheck ttl = strings.Title(raw) } } diff --git a/commit_parser_test.go b/commit_parser_test.go index 93eec18b..600d1163 100644 --- a/commit_parser_test.go +++ b/commit_parser_test.go @@ -3,7 +3,6 @@ package chglog import ( "errors" "fmt" - "io/ioutil" "os" "path/filepath" "testing" @@ -23,7 +22,7 @@ func TestCommitParserParse(t *testing.T) { return "", errors.New("") } - bytes, _ := ioutil.ReadFile(filepath.Join("testdata", "gitlog.txt")) + bytes, _ := os.ReadFile(filepath.Join("testdata", "gitlog.txt")) return string(bytes), nil }, @@ -376,7 +375,7 @@ func TestCommitParserParseWithJira(t *testing.T) { return "", errors.New("") } - bytes, _ := ioutil.ReadFile(filepath.Join("testdata", "gitlog_jira.txt")) + bytes, _ := os.ReadFile(filepath.Join("testdata", "gitlog_jira.txt")) return string(bytes), nil }, diff --git a/go.mod b/go.mod index 6eddc45c..bcf5f266 100644 --- a/go.mod +++ b/go.mod @@ -1,18 +1,48 @@ module github.com/git-chglog/git-chglog -go 1.16 +go 1.24.1 require ( - github.com/AlecAivazis/survey/v2 v2.2.9 - github.com/Masterminds/sprig/v3 v3.2.2 - github.com/andygrunwald/go-jira v1.13.0 - github.com/coreos/go-semver v0.3.0 - github.com/fatih/color v1.10.0 - github.com/imdario/mergo v0.3.12 - github.com/kyokomi/emoji/v2 v2.2.8 - github.com/mattn/go-colorable v0.1.8 - github.com/stretchr/testify v1.7.0 + github.com/AlecAivazis/survey/v2 v2.3.7 + github.com/Masterminds/sprig/v3 v3.3.0 + github.com/andygrunwald/go-jira v1.16.0 + github.com/coreos/go-semver v0.3.1 + github.com/fatih/color v1.18.0 + github.com/imdario/mergo v0.3.16 + github.com/kyokomi/emoji/v2 v2.2.13 + github.com/mattn/go-colorable v0.1.14 + github.com/stretchr/testify v1.10.0 github.com/tsuyoshiwada/go-gitcmd v0.0.0-20180205145712-5f1f5f9475df - github.com/urfave/cli/v2 v2.3.0 - gopkg.in/yaml.v2 v2.4.0 + github.com/urfave/cli/v2 v2.27.6 + gopkg.in/yaml.v2 v2.3.0 + gopkg.in/yaml.v3 v3.0.1 +) + +require ( + dario.cat/mergo v1.0.1 // indirect + github.com/Masterminds/goutils v1.1.1 // indirect + github.com/Masterminds/semver/v3 v3.3.0 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/fatih/structs v1.1.0 // indirect + github.com/golang-jwt/jwt/v4 v4.4.2 // indirect + github.com/google/go-querystring v1.1.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/huandu/xstrings v1.5.0 // indirect + github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect + github.com/mitchellh/copystructure v1.2.0 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/shopspring/decimal v1.4.0 // indirect + github.com/spf13/cast v1.7.0 // indirect + github.com/trivago/tgo v1.0.7 // indirect + github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect + golang.org/x/crypto v0.26.0 // indirect + golang.org/x/sys v0.29.0 // indirect + golang.org/x/term v0.23.0 // indirect + golang.org/x/text v0.17.0 // indirect ) diff --git a/go.sum b/go.sum index aa19b196..737e6111 100644 --- a/go.sum +++ b/go.sum @@ -1,105 +1,135 @@ -github.com/AlecAivazis/survey/v2 v2.2.9 h1:LWvJtUswz/W9/zVVXELrmlvdwWcKE60ZAw0FWV9vssk= -github.com/AlecAivazis/survey/v2 v2.2.9/go.mod h1:9DYvHgXtiXm6nCn+jXnOXLKbH+Yo9u8fAS/SduGdoPk= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= +dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ= +github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= -github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8= -github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= -github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8 h1:xzYJEypr/85nBpB11F9br+3HUrpgb+fcm5iADzXXYEw= -github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc= -github.com/andygrunwald/go-jira v1.13.0 h1:vvIImGgX32bHfoiyUwkNo+/YrPnRczNarvhLOncP6dE= -github.com/andygrunwald/go-jira v1.13.0/go.mod h1:jYi4kFDbRPZTJdJOVJO4mpMMIwdB+rcZwSO58DzPd2I= -github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -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/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0= +github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= +github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs= +github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0= +github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s= +github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w= +github.com/andygrunwald/go-jira v1.16.0 h1:PU7C7Fkk5L96JvPc6vDVIrd99vdPnYudHu4ju2c2ikQ= +github.com/andygrunwald/go-jira v1.16.0/go.mod h1:UQH4IBVxIYWbgagc0LF/k9FRs9xjIiQ8hIcC6HfLwFU= +github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4= +github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec= +github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= +github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI= +github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg= -github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= -github.com/fatih/structs v1.0.0 h1:BrX964Rv5uQ3wwS+KRUAJCBBw5PQmgJfJ6v4yly5QwU= -github.com/fatih/structs v1.0.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= -github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 h1:zLTLjkaOFEFIOxY5BWLFLwh+cL8vOBW4XJ2aqLE/Tf0= -github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDGgJGQpNflI3+MJSBhsgT5PCtzBQ= -github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A= -github.com/huandu/xstrings v1.3.1 h1:4jgBlKK6tLKFvO8u5pmYjG91cqytmDCDvGh7ECVFfFs= -github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= -github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= +github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= +github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= +github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= +github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog= +github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68= +github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI= +github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= +github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= -github.com/kr/pty v1.1.4 h1:5Myjjh3JY/NaAi4IsUbHADytDyl1VE1Y9PXDlL+P/VQ= -github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kyokomi/emoji/v2 v2.2.8 h1:jcofPxjHWEkJtkIbcLHvZhxKgCPl6C7MyjTrD4KDqUE= -github.com/kyokomi/emoji/v2 v2.2.8/go.mod h1:JUcn42DTdsXJo1SWanHh4HKDEyPaR5CqkmoirZZP9qE= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kyokomi/emoji/v2 v2.2.13 h1:GhTfQa67venUUvmleTNFnb+bi7S3aocF7ZCXU9fSO7U= +github.com/kyokomi/emoji/v2 v2.2.13/go.mod h1:JUcn42DTdsXJo1SWanHh4HKDEyPaR5CqkmoirZZP9qE= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -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-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= -github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= -github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= -github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY= -github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= -github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -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/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +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/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= +github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= +github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w= +github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/trivago/tgo v1.0.1 h1:bxatjJIXNIpV18bucU4Uk/LaoxvxuOlp/oowRHyncLQ= -github.com/trivago/tgo v1.0.1/go.mod h1:w4dpD+3tzNIIiIfkWWa85w5/B77tlvdZckQ+6PkFnhc= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/trivago/tgo v1.0.7 h1:uaWH/XIy9aWYWpjm2CU3RpcqZXmX2ysQ9/Go+d9gyrM= +github.com/trivago/tgo v1.0.7/go.mod h1:w4dpD+3tzNIIiIfkWWa85w5/B77tlvdZckQ+6PkFnhc= github.com/tsuyoshiwada/go-gitcmd v0.0.0-20180205145712-5f1f5f9475df h1:Y2l28Jr3vOEeYtxfVbMtVfOdAwuUqWaP9fvNKiBVeXY= github.com/tsuyoshiwada/go-gitcmd v0.0.0-20180205145712-5f1f5f9475df/go.mod h1:pnyouUty/nBr/zm3GYwTIt+qFTLWbdjeLjZmJdzJOu8= -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= +github.com/urfave/cli/v2 v2.27.6 h1:VdRdS98FNhKZ8/Az8B7MTyGQmpIr36O1EHybx/LaZ4g= +github.com/urfave/cli/v2 v2.27.6/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= +github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= +github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200414173820-0848c9571904 h1:bXoxMPcSLOq08zI3/c5dEBT6lE4eh+jOh886GHrn6V8= -golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190530182044-ad28b68e88f1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= +golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +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.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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/processor.go b/processor.go index 505fec6c..194fccd6 100644 --- a/processor.go +++ b/processor.go @@ -14,8 +14,8 @@ type Processor interface { // GitHubProcessor is optimized for CHANGELOG used in GitHub // // The following processing is performed -// - Mentions automatic link (@tsuyoshiwada -> [@tsuyoshiwada](https://github.com/tsuyoshiwada)) -// - Automatic link to references (#123 -> [#123](https://github.com/owner/repo/issues/123)) +// - Mentions automatic link (@tsuyoshiwada -> [@tsuyoshiwada](https://github.com/tsuyoshiwada)) +// - Automatic link to references (#123 -> [#123](https://github.com/owner/repo/issues/123)) type GitHubProcessor struct { Host string // Host name used for link destination. Note: You must include the protocol (e.g. "https://github.com") config *Config @@ -69,13 +69,15 @@ func (p *GitHubProcessor) addLinks(input string) string { // GitLabProcessor is optimized for CHANGELOG used in GitLab // // The following processing is performed -// - Mentions automatic link (@tsuyoshiwada -> [@tsuyoshiwada](https://gitlab.com/tsuyoshiwada)) -// - Automatic link to references (#123 -> [#123](https://gitlab.com/owner/repo/issues/123)) +// - Mentions automatic link (@tsuyoshiwada -> [@tsuyoshiwada](https://gitlab.com/tsuyoshiwada)) +// - Automatic link to references issues (#123 -> [#123](https://gitlab.com/owner/repo/issues/123)) +// - Automatic link to references merge request (!123 -> [#123](https://gitlab.com/owner/repo/merge_requests/123)) type GitLabProcessor struct { - Host string // Host name used for link destination. Note: You must include the protocol (e.g. "https://gitlab.com") - config *Config - reMention *regexp.Regexp - reIssue *regexp.Regexp + Host string // Host name used for link destination. Note: You must include the protocol (e.g. "https://gitlab.com") + config *Config + reMention *regexp.Regexp + reIssue *regexp.Regexp + reMergeRequest *regexp.Regexp } // Bootstrap ... @@ -90,6 +92,7 @@ func (p *GitLabProcessor) Bootstrap(config *Config) { p.reMention = regexp.MustCompile(`@(\w+)`) p.reIssue = regexp.MustCompile(`(?i)#(\d+)`) + p.reMergeRequest = regexp.MustCompile(`(?i)!(\d+)`) } // ProcessCommit ... @@ -118,14 +121,17 @@ func (p *GitLabProcessor) addLinks(input string) string { // issues input = p.reIssue.ReplaceAllString(input, "[#$1]("+repoURL+"/issues/$1)") + // merge requests + input = p.reMergeRequest.ReplaceAllString(input, "[!$1]("+repoURL+"/merge_requests/$1)") + return input } // BitbucketProcessor is optimized for CHANGELOG used in Bitbucket // // The following processing is performed -// - Mentions automatic link (@tsuyoshiwada -> [@tsuyoshiwada](https://bitbucket.org/tsuyoshiwada/)) -// - Automatic link to references (#123 -> [#123](https://bitbucket.org/owner/repo/issues/123/)) +// - Mentions automatic link (@tsuyoshiwada -> [@tsuyoshiwada](https://bitbucket.org/tsuyoshiwada/)) +// - Automatic link to references (#123 -> [#123](https://bitbucket.org/owner/repo/issues/123/)) type BitbucketProcessor struct { Host string // Host name used for link destination. Note: You must include the protocol (e.g. "https://bitbucket.org") config *Config diff --git a/processor_test.go b/processor_test.go index 88e8502e..1b15bd3f 100644 --- a/processor_test.go +++ b/processor_test.go @@ -83,30 +83,34 @@ func TestGitLabProcessor(t *testing.T) { assert.Equal( &Commit{ - Header: "message [@foo](https://gitlab.com/foo) [#123](https://example.com/issues/123)", - Subject: "message [@foo](https://gitlab.com/foo) [#123](https://example.com/issues/123)", + Header: "message [@foo](https://gitlab.com/foo) [#123](https://example.com/issues/123) [!345](https://example.com/merge_requests/345)", + Subject: "message [@foo](https://gitlab.com/foo) [#123](https://example.com/issues/123) [!345](https://example.com/merge_requests/345)", Body: `issue [#456](https://example.com/issues/456) multiline [#789](https://example.com/issues/789) +merge request [!345](https://example.com/merge_requests/345) [@foo](https://gitlab.com/foo), [@bar](https://gitlab.com/bar)`, Notes: []*Note{ { - Body: `issue1 [#11](https://example.com/issues/11) + Body: `issue1 [#11](https://example.com/issues/11) [!33](https://example.com/merge_requests/33) issue2 [#22](https://example.com/issues/22) +merge request [!33](https://example.com/merge_requests/33) gh-56 hoge fuga`, }, }, }, processor.ProcessCommit( &Commit{ - Header: "message @foo #123", - Subject: "message @foo #123", + Header: "message @foo #123 !345", + Subject: "message @foo #123 !345", Body: `issue #456 multiline #789 +merge request !345 @foo, @bar`, Notes: []*Note{ { - Body: `issue1 #11 + Body: `issue1 #11 !33 issue2 #22 +merge request !33 gh-56 hoge fuga`, }, }, @@ -117,13 +121,13 @@ gh-56 hoge fuga`, assert.Equal( &Commit{ Revert: &Revert{ - Header: "revert header [@mention](https://gitlab.com/mention) [#123](https://example.com/issues/123)", + Header: "revert header [@mention](https://gitlab.com/mention) [#123](https://example.com/issues/123) [!345](https://example.com/merge_requests/345)", }, }, processor.ProcessCommit( &Commit{ Revert: &Revert{ - Header: "revert header @mention #123", + Header: "revert header @mention #123 !345", }, }, ), diff --git a/tag_reader.go b/tag_reader.go index 754cb633..fb2cc3f4 100644 --- a/tag_reader.go +++ b/tag_reader.go @@ -91,10 +91,7 @@ func (*tagReader) filterSemVerTags(tags *[]*Tag) { for i, t := range *tags { // remove leading v, since its so // common. - name := t.Name - if strings.HasPrefix(name, "v") { - name = strings.TrimPrefix(name, "v") - } + name := strings.TrimPrefix(t.Name, "v") // attempt semver parse, if not successful // remove it from tags slice. diff --git a/utils.go b/utils.go index a67a29ad..ccf866a3 100644 --- a/utils.go +++ b/utils.go @@ -23,6 +23,7 @@ func dotGet(target interface{}, prop string) (interface{}, bool) { value = reflect.ValueOf(target) } + //nolint:staticcheck field := value.FieldByName(strings.Title(key)) if !field.IsValid() { return nil, false