build(deps): bump github.com/vbatts/git-validation in /test/tools

Bumps [github.com/vbatts/git-validation](https://github.com/vbatts/git-validation) from 1.1.0 to 1.2.0.
- [Release notes](https://github.com/vbatts/git-validation/releases)
- [Commits](https://github.com/vbatts/git-validation/compare/v1.1.0...v1.2.0)

---
updated-dependencies:
- dependency-name: github.com/vbatts/git-validation
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2023-03-15 13:00:58 +00:00
committed by GitHub
parent 68bf49799d
commit 2b4a27719c
64 changed files with 24001 additions and 294 deletions

View File

@ -4,10 +4,7 @@ go_import_path: github.com/vbatts/git-validation
go:
- "tip"
- "1.x"
- "1.11.x"
- "1.10.x"
- "1.9.x"
- "1.13.x"
env:
@ -27,10 +24,8 @@ before_script:
before_install:
- go get ./...
- if [[ "$(go version |awk '{ print $3 }')" =~ ^go1\.11\. ]] ; then go get -u golang.org/x/lint/golint ; fi
script:
- if [[ "$(go version |awk '{ print $3 }')" =~ ^go1\.11\. ]] ; then golint -set_exit_status ./... ; fi
- go vet -x ./...
- go build .
- go test -v ./...

View File

@ -1,18 +1,20 @@
# git-validation
A way to do validation on git commits.
[![Build Status](https://travis-ci.org/vbatts/git-validation.svg?branch=master)](https://travis-ci.org/vbatts/git-validation)
[![Travis Status](https://travis-ci.org/vbatts/git-validation.svg?branch=master)](https://travis-ci.org/vbatts/git-validation)
[![GithubActions Status](https://github.com/vbatts/git-validation/actions/workflows/go.yml/badge.svg)](https://github.com/vbatts/git-validation/actions/workflows/go.yml)
## install
```console
vbatts@valse ~ (master) $ go get -u github.com/vbatts/git-validation
```shell
go install github.com/vbatts/git-validation@latest
```
## usage
The flags
```console
```shell
vbatts@valse ~/src/vb/git-validation (master *) $ git-validation -h
Usage of git-validation:
-D debug output
@ -28,7 +30,8 @@ Usage of git-validation:
```
The entire default rule set is run by default:
```console
```shell
vbatts@valse ~/src/vb/git-validation (master) $ git-validation -list-rules
"dangling-whitespace" -- checking the presence of dangling whitespaces on line endings
"DCO" -- makes sure the commits are signed
@ -37,7 +40,8 @@ vbatts@valse ~/src/vb/git-validation (master) $ git-validation -list-rules
```
Or, specify comma-delimited rules to run:
```console
```shell
vbatts@valse ~/src/vb/git-validation (master) $ git-validation -run DCO,short-subject
* b243ca4 "README: adding install and usage" ... PASS
* d614ccf "*: run tests in a runner" ... PASS
@ -49,7 +53,8 @@ vbatts@valse ~/src/vb/git-validation (master) $ git-validation -run DCO,short-su
```
Verbosity shows each rule's output:
```console
```shell
vbatts@valse ~/src/vb/git-validation (master) $ git-validation -v
* d614ccf "*: run tests in a runner" ... PASS
- PASS - has a valid DCO
@ -72,7 +77,8 @@ vbatts@valse ~/src/vb/git-validation (master) $ git-validation -v
```
Here's a failure:
```console
```shell
vbatts@valse ~/src/vb/git-validation (master) $ git-validation
* 49f51a8 "README: adding install and usage" ... FAIL
- FAIL - does not have a valid DCO
@ -88,12 +94,13 @@ vbatts@valse ~/src/vb/git-validation (master) $ echo $?
```
Excluding paths that are out of the scope of your project:
```console
```shell
vbatts@valse ~/src/vb/git-validation (master) $ GIT_CHECK_EXCLUDE="./vendor:./git/testdata" git-validation -q -run dangling-whitespace
...
```
using the `GIT_CHECK_EXCLUDE` environment variable. Multiple paths should be separated by colon(`:`)
using the `GIT_CHECK_EXCLUDE` environment variable. Multiple paths should be separated by colon(`:`)
## Rules
@ -103,4 +110,3 @@ See [`./rules/`](./rules/).
Feel free to contribute more.
Otherwise, by using `validate` package API directly, rules can be handed directly to the `validate.Runner`.

View File

@ -15,7 +15,7 @@ import (
// If commitrange is a single commit, all ancestor commits up through the hash provided.
// If commitrange is an empty commit range, then nil is returned.
func Commits(commitrange string) ([]CommitEntry, error) {
cmdArgs := []string{"git", "--no-pager", "log", `--pretty=format:%H`, commitrange}
cmdArgs := []string{"git", "rev-list", commitrange}
if debug() {
logrus.Infof("[git] cmd: %q", strings.Join(cmdArgs, " "))
}
@ -153,7 +153,8 @@ func LogCommit(commit string) (*CommitEntry, error) {
logrus.Errorf("[git] cmd: %q", strings.Join(cmd.Args, " "))
return nil, err
}
c[v] = strings.TrimSpace(string(out))
commitMessage := strings.ReplaceAll(string(out), "\r\n", "\n")
c[v] = strings.TrimSpace(commitMessage)
}
return &c, nil

View File

@ -22,6 +22,7 @@ var (
flDebug = flag.Bool("D", false, "debug output")
flQuiet = flag.Bool("q", false, "less output")
flDir = flag.String("d", ".", "git directory to validate from")
flNoGithub = flag.Bool("no-github", false, "disables Github Actions environment checks (when env GITHUB_ACTIONS=true is set)")
flNoTravis = flag.Bool("no-travis", false, "disables travis environment checks (when env TRAVIS=true is set)")
flTravisPROnly = flag.Bool("travis-pr-only", true, "when on travis, only run validations if the CI-Build is checking pull-request build")
)
@ -73,6 +74,10 @@ func main() {
commitRange = os.Getenv("TRAVIS_COMMIT")
}
}
// https://docs.github.com/en/actions/reference/environment-variables
if strings.ToLower(os.Getenv("GITHUB_ACTIONS")) == "true" && !*flNoGithub {
commitRange = fmt.Sprintf("%s..%s", os.Getenv("GITHUB_SHA"), "HEAD")
}
}
runner, err := validate.NewRunner(*flDir, rules, commitRange, *flVerbose)