coreos/git-validation

Name: git-validation

Owner: CoreOS

Description: utility for validating git commits (in a CI like travis or jenkins)

Forked from: vbatts/git-validation

Created: 2016-05-19 11:40:31.0

Updated: 2017-09-21 14:30:53.0

Pushed: 2016-05-24 15:02:01.0

Homepage: null

Size: 28

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

git-validation

A way to do validation on git commits. Build Status

install
ts@valse ~ (master) $ go get -u github.com/vbatts/git-validation
usage

The flags

ts@valse ~/src/vb/git-validation (master *) $ git-validation -h
e of git-validation:
    debug output
 string
    git directory to validate from (default ".")
ist-rules
    list the rules registered
ange string
    use this commit range instead
un string
    comma delimited list of rules to run. Defaults to all.
    verbose

The entire default rule set is run by default:

ts@valse ~/src/vb/git-validation (master) $ git-validation -list-rules
" -- makes sure the commits are signed
rt-subject" -- commit subjects are strictly less than 90 (github ellipsis length)

Or, specify comma-delimited rules to run:

ts@valse ~/src/vb/git-validation (master) $ git-validation -run DCO,short-subject
243ca4 "README: adding install and usage" ... PASS
614ccf "*: run tests in a runner" ... PASS
9413c6 "shortsubject: add a subject length check" ... PASS
e74abd "*: comments and golint" ... PASS
7a982f "git: add verbose output of the commands run" ... PASS
3bda4b "main: add filtering of rules to run" ... PASS
10ba9c "Initial commit" ... PASS

Verbosity shows each rule's output:

ts@valse ~/src/vb/git-validation (master) $ git-validation -v
614ccf "*: run tests in a runner" ... PASS
PASS - has a valid DCO
PASS - commit subject is 72 characters or less! *yay*
9413c6 "shortsubject: add a subject length check" ... PASS
PASS - has a valid DCO
PASS - commit subject is 72 characters or less! *yay*
e74abd "*: comments and golint" ... PASS
PASS - has a valid DCO
PASS - commit subject is 72 characters or less! *yay*
7a982f "git: add verbose output of the commands run" ... PASS
PASS - has a valid DCO
PASS - commit subject is 72 characters or less! *yay*
3bda4b "main: add filtering of rules to run" ... PASS
PASS - has a valid DCO
PASS - commit subject is 72 characters or less! *yay*
10ba9c "Initial commit" ... PASS
PASS - has a valid DCO
PASS - commit subject is 72 characters or less! *yay*

Here's a failure:

ts@valse ~/src/vb/git-validation (master) $ git-validation 
9f51a8 "README: adding install and usage" ... FAIL
FAIL - does not have a valid DCO
614ccf "*: run tests in a runner" ... PASS
9413c6 "shortsubject: add a subject length check" ... PASS
e74abd "*: comments and golint" ... PASS
7a982f "git: add verbose output of the commands run" ... PASS
3bda4b "main: add filtering of rules to run" ... PASS
10ba9c "Initial commit" ... PASS
sues to fix
ts@valse ~/src/vb/git-validation (master) $ echo $?

Rules

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

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


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.