diff --git a/README.md b/README.md index f635a73..2e09777 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,14 @@ $ ./gitlint --help usage: gitlint [] Flags: - --help Show context-sensitive help (also try --help-long and --help-man). - --path="." Path to the git repo (default: "."). - --subject-regex=".*" Commit subject line must conform to this regular expression (default: ".*"). - --subject-len=2147483646 Commit subject line cannot exceed this length (default: math.MaxInt32 - 1). - --body-regex=".*" Commit message body must conform to this regular expression (default: ".*"). - --since="1970-01-01" A date in "yyyy-MM-dd" format starting from which commits will be analyzed (default: "1970-01-01"). - --msg-file="" Only analyze the commit message found in this file (default: ""). - --max-parents=1 Max number of parents a commit can have in order to be analyzed (default: 1). Useful for excluding merge commits. + --help Show context-sensitive help (also try --help-long and --help-man). + --path="." Path to the git repo (default: "."). + --subject-regex=".*" Commit subject line must conform to this regular expression (default: ".*"). + --subject-maxlen=2147483646 Max length for commit subject line (default: math.MaxInt32 - 1). + --body-regex=".*" Commit message body must conform to this regular expression (default: ".*"). + --since="1970-01-01" A date in "yyyy-MM-dd" format starting from which commits will be analyzed (default: "1970-01-01"). + --msg-file="" Only analyze the commit message found in this file (default: ""). + --max-parents=1 Max number of parents a commit can have in order to be analyzed (default: 1). Useful for excluding merge commits. ``` Additionally, it will look for configurations in a file `.gitlint` in the current directory if it exists. This file's format is just the same command line flags but each on a separate line. *Flags passed through the command line take precedence.* diff --git a/cmd/go-gitlint/main.go b/cmd/go-gitlint/main.go index df3a787..1d8edb6 100644 --- a/cmd/go-gitlint/main.go +++ b/cmd/go-gitlint/main.go @@ -30,13 +30,13 @@ import ( // Figure out a way to remove these global variables. Whatever command line // parser we choose should be able to auto-generate usage. var ( - path = kingpin.Flag("path", `Path to the git repo (default: ".").`).Default(".").String() //nolint[gochecknoglobals] - subjectRegex = kingpin.Flag("subject-regex", `Commit subject line must conform to this regular expression (default: ".*").`).Default(".*").String() //nolint[gochecknoglobals] - subjectLength = kingpin.Flag("subject-len", "Commit subject line cannot exceed this length (default: math.MaxInt32 - 1).").Default(strconv.Itoa(math.MaxInt32 - 1)).Int() //nolint[gochecknoglobals] - bodyRegex = kingpin.Flag("body-regex", `Commit message body must conform to this regular expression (default: ".*").`).Default(".*").String() //nolint[gochecknoglobals] - since = kingpin.Flag("since", `A date in "yyyy-MM-dd" format starting from which commits will be analyzed (default: "1970-01-01").`).Default("1970-01-01").String() //nolint[gochecknoglobals] - msgFile = kingpin.Flag("msg-file", `Only analyze the commit message found in this file (default: "").`).Default("").String() //nolint[gochecknoglobals] - maxParents = kingpin.Flag("max-parents", `Max number of parents a commit can have in order to be analyzed (default: 1). Useful for excluding merge commits.`).Default("1").Int() //nolint[gochecknoglobals] + path = kingpin.Flag("path", `Path to the git repo (default: ".").`).Default(".").String() //nolint[gochecknoglobals] + subjectRegex = kingpin.Flag("subject-regex", `Commit subject line must conform to this regular expression (default: ".*").`).Default(".*").String() //nolint[gochecknoglobals] + subjectMaxLength = kingpin.Flag("subject-maxlen", "Max length for commit subject line (default: math.MaxInt32 - 1).").Default(strconv.Itoa(math.MaxInt32 - 1)).Int() //nolint[gochecknoglobals] + bodyRegex = kingpin.Flag("body-regex", `Commit message body must conform to this regular expression (default: ".*").`).Default(".*").String() //nolint[gochecknoglobals] + since = kingpin.Flag("since", `A date in "yyyy-MM-dd" format starting from which commits will be analyzed (default: "1970-01-01").`).Default("1970-01-01").String() //nolint[gochecknoglobals] + msgFile = kingpin.Flag("msg-file", `Only analyze the commit message found in this file (default: "").`).Default("").String() //nolint[gochecknoglobals] + maxParents = kingpin.Flag("max-parents", `Max number of parents a commit can have in order to be analyzed (default: 1). Useful for excluding merge commits.`).Default("1").Int() //nolint[gochecknoglobals] ) func main() { @@ -49,7 +49,7 @@ func main() { []issues.Filter{ issues.OfSubjectRegex(*subjectRegex), issues.OfBodyRegex(*bodyRegex), - issues.OfSubjectLength(*subjectLength), + issues.OfSubjectLength(*subjectMaxLength), }, try( len(*msgFile) > 0,