aboutsummaryrefslogtreecommitdiff
path: root/test/tools/vendor/github.com/vbatts/git-validation/README.md
blob: 354276e02ffcfea4ce9151a3f8e674f75af19cf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# 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)

## install

```console
vbatts@valse ~ (master) $ go get -u github.com/vbatts/git-validation
```

## usage

The flags
```console
vbatts@valse ~/src/vb/git-validation (master *) $ git-validation -h
Usage of git-validation:
  -D    debug output
  -d string
        git directory to validate from (default ".")
  -list-rules
        list the rules registered
  -range string
        use this commit range instead
  -run string
        comma delimited list of rules to run. Defaults to all.
  -v    verbose
```

The entire default rule set is run by default:
```console
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
"message_regexp" -- checks the commit message for a user provided regular expression
"short-subject" -- commit subjects are strictly less than 90 (github ellipsis length)
```

Or, specify comma-delimited rules to run:
```console
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
 * b9413c6 "shortsubject: add a subject length check" ... PASS
 * 5e74abd "*: comments and golint" ... PASS
 * 07a982f "git: add verbose output of the commands run" ... PASS
 * 03bda4b "main: add filtering of rules to run" ... PASS
 * c10ba9c "Initial commit" ... PASS
```

Verbosity shows each rule's output:
```console
vbatts@valse ~/src/vb/git-validation (master) $ git-validation -v
 * d614ccf "*: run tests in a runner" ... PASS
  - PASS - has a valid DCO
  - PASS - commit subject is 72 characters or less! *yay*
 * b9413c6 "shortsubject: add a subject length check" ... PASS
  - PASS - has a valid DCO
  - PASS - commit subject is 72 characters or less! *yay*
 * 5e74abd "*: comments and golint" ... PASS
  - PASS - has a valid DCO
  - PASS - commit subject is 72 characters or less! *yay*
 * 07a982f "git: add verbose output of the commands run" ... PASS
  - PASS - has a valid DCO
  - PASS - commit subject is 72 characters or less! *yay*
 * 03bda4b "main: add filtering of rules to run" ... PASS
  - PASS - has a valid DCO
  - PASS - commit subject is 72 characters or less! *yay*
 * c10ba9c "Initial commit" ... PASS
  - PASS - has a valid DCO
  - PASS - commit subject is 72 characters or less! *yay*
```

Here's a failure:
```console
vbatts@valse ~/src/vb/git-validation (master) $ git-validation 
 * 49f51a8 "README: adding install and usage" ... FAIL
  - FAIL - does not have a valid DCO
 * d614ccf "*: run tests in a runner" ... PASS
 * b9413c6 "shortsubject: add a subject length check" ... PASS
 * 5e74abd "*: comments and golint" ... PASS
 * 07a982f "git: add verbose output of the commands run" ... PASS
 * 03bda4b "main: add filtering of rules to run" ... PASS
 * c10ba9c "Initial commit" ... PASS
1 issues to fix
vbatts@valse ~/src/vb/git-validation (master) $ echo $?
1
```

Excluding paths that are out of the scope of your project:
```console
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(`:`)


## Rules

Default rules are added by registering them to the `validate` package.
Usually by putting them in their own package.
See [`./rules/`](./rules/).
Feel free to contribute more.

Otherwise, by using `validate` package API directly, rules can be handed directly to the `validate.Runner`.