diff options
| author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-05-05 05:53:18 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-05 05:53:18 -0400 |
| commit | 88f8d398b357c60f8b78b8dedf1e1515a534b873 (patch) | |
| tree | 6e3fa55f6c32b95c883480844193443b97540531 /test/tools/vendor/github.com/vbatts/git-validation/rules/danglingwhitespace | |
| parent | 7af4612d6b969329a78b4945c35a641449989a2d (diff) | |
| parent | 3866143675a2ccf15095b75b2c97b858d8ef0ab5 (diff) | |
| download | podman-88f8d398b357c60f8b78b8dedf1e1515a534b873.tar.gz podman-88f8d398b357c60f8b78b8dedf1e1515a534b873.tar.bz2 podman-88f8d398b357c60f8b78b8dedf1e1515a534b873.zip | |
Merge pull request #14098 from Luap99/test-tools
vendor test dependencies instead of installing via network
Diffstat (limited to 'test/tools/vendor/github.com/vbatts/git-validation/rules/danglingwhitespace')
| -rw-r--r-- | test/tools/vendor/github.com/vbatts/git-validation/rules/danglingwhitespace/rule.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/tools/vendor/github.com/vbatts/git-validation/rules/danglingwhitespace/rule.go b/test/tools/vendor/github.com/vbatts/git-validation/rules/danglingwhitespace/rule.go new file mode 100644 index 000000000..dab3a984b --- /dev/null +++ b/test/tools/vendor/github.com/vbatts/git-validation/rules/danglingwhitespace/rule.go @@ -0,0 +1,39 @@ +package danglingwhitespace + +import ( + "github.com/vbatts/git-validation/git" + "github.com/vbatts/git-validation/validate" +) + +var ( + // DanglingWhitespace is the rule for checking the presence of dangling + // whitespaces on line endings. + DanglingWhitespace = validate.Rule{ + Name: "dangling-whitespace", + Description: "checking the presence of dangling whitespaces on line endings", + Run: ValidateDanglingWhitespace, + Default: true, + } +) + +func init() { + validate.RegisterRule(DanglingWhitespace) +} + +// ValidateDanglingWhitespace runs Git's check to look for whitespace errors. +func ValidateDanglingWhitespace(r validate.Rule, c git.CommitEntry) (vr validate.Result) { + vr.CommitEntry = c + vr.Msg = "commit does not have any whitespace errors" + vr.Pass = true + + _, err := git.Check(c["commit"]) + if err != nil { + vr.Pass = false + if err.Error() == "exit status 2" { + vr.Msg = "has whitespace errors. See `git show --check " + c["commit"] + "`." + } else { + vr.Msg = "errored with: " + err.Error() + } + } + return +} |
