mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-23 02:15:12 +00:00
chore(ci): add golangci-lint action and apply linting changes (#120)
BREAKING CHANGE: `JiraIssueId` has been renamed to `JiraIssueID`. This impacts the value for `pattern_maps` in `config.yml`. * chore(ci): add golangci-lint action * chore(lint): address errcheck lint failures * chore(lint): address misspell lint failures * chore(lint): address gocritic lint failures * chore(lint): address golint lint failures * chore(lint): address structcheck lint failures * chore(lint): address gosimple lint failures * chore(lint): address gofmt lint failures * chore(ci): port to official golangci-lint github action * Update golangci configuration for better coverage Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com> * fix: file is not goimports-ed Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com> * fix: golint and exported functions comments Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com> * chore(lint): address gosec G304 warning * chore(lint): address uparam warnings * chore(lint): address scopelint lint failures * fix: cyclomatic complexity Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com> * chore(lint): address prealloc warning, noting that we are warning for now * chore(lint): address govet and errorlint failures * chore: clean up defer logic when checking errors Co-authored-by: Khosrow Moossavi <khos2ow@gmail.com>
This commit is contained in:
parent
2c3d3f400e
commit
ae3382b7c8
37 changed files with 391 additions and 177 deletions
39
chglog.go
39
chglog.go
|
|
@ -5,13 +5,14 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
gitcmd "github.com/tsuyoshiwada/go-gitcmd"
|
||||
"github.com/tsuyoshiwada/go-gitcmd"
|
||||
)
|
||||
|
||||
// Options is an option used to process commits
|
||||
|
|
@ -37,7 +38,7 @@ type Options struct {
|
|||
NoteKeywords []string // Keyword list to find `Note`. A semicolon is a separator, like `<keyword>:` (e.g. `BREAKING CHANGE`)
|
||||
JiraUsername string
|
||||
JiraToken string
|
||||
JiraUrl string
|
||||
JiraURL string
|
||||
JiraTypeMaps map[string]string
|
||||
JiraIssueDescriptionPattern string
|
||||
Paths []string // Path filter
|
||||
|
|
@ -138,7 +139,11 @@ func (gen *Generator) Generate(w io.Writer, query string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer back()
|
||||
defer func() {
|
||||
if err = back(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
||||
tags, first, err := gen.getTags(query)
|
||||
if err != nil {
|
||||
|
|
@ -269,7 +274,7 @@ func (gen *Generator) getTags(query string) ([]*Tag, string, error) {
|
|||
|
||||
// Assign the date with `readVersions()`
|
||||
tags = append([]*Tag{
|
||||
&Tag{
|
||||
{
|
||||
Name: next,
|
||||
Subject: next,
|
||||
Previous: previous,
|
||||
|
|
@ -318,30 +323,18 @@ func (gen *Generator) render(w io.Writer, unreleased *Unreleased, versions []*Ve
|
|||
"datetime": func(layout string, input time.Time) string {
|
||||
return input.Format(layout)
|
||||
},
|
||||
// check whether substs is withing s
|
||||
"contains": func(s, substr string) bool {
|
||||
return strings.Contains(s, substr)
|
||||
},
|
||||
// check whether substr is within s
|
||||
"contains": strings.Contains,
|
||||
// check whether s begins with prefix
|
||||
"hasPrefix": func(s, prefix string) bool {
|
||||
return strings.HasPrefix(s, prefix)
|
||||
},
|
||||
"hasPrefix": strings.HasPrefix,
|
||||
// check whether s ends with suffix
|
||||
"hasSuffix": func(s, suffix string) bool {
|
||||
return strings.HasSuffix(s, suffix)
|
||||
},
|
||||
"hasSuffix": strings.HasSuffix,
|
||||
// replace the first n instances of old with new
|
||||
"replace": func(s, old, new string, n int) string {
|
||||
return strings.Replace(s, old, new, n)
|
||||
},
|
||||
"replace": strings.Replace,
|
||||
// lower case a string
|
||||
"lower": func(s string) string {
|
||||
return strings.ToLower(s)
|
||||
},
|
||||
"lower": strings.ToLower,
|
||||
// upper case a string
|
||||
"upper": func(s string) string {
|
||||
return strings.ToUpper(s)
|
||||
},
|
||||
"upper": strings.ToUpper,
|
||||
// upper case the first character of a string
|
||||
"upperFirst": func(s string) string {
|
||||
if len(s) > 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue