diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..15a15b2
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/Gopkg.lock b/Gopkg.lock
index cdfcf05..6c01b27 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -25,6 +25,12 @@
revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183"
version = "v2.2.1"
+[[projects]]
+ name = "livingit.de/code/go-hookhelper"
+ packages = ["."]
+ revision = "8271b504d319691690f673cd07e05be638d95df4"
+ version = "0.1.0"
+
[[projects]]
name = "livingit.de/code/versioned"
packages = ["."]
@@ -34,6 +40,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
- inputs-digest = "67d9f4ba14859b517224764934a28345465d5fcb14925413d070c02d6a3d19c0"
+ inputs-digest = "91c02958be7074fa146ce76e315828829f294a46ff85ebcb52c3262539443bb7"
solver-name = "gps-cdcl"
solver-version = 1
diff --git a/Gopkg.toml b/Gopkg.toml
index 4dc3569..c4125ca 100644
--- a/Gopkg.toml
+++ b/Gopkg.toml
@@ -41,6 +41,10 @@
name = "gopkg.in/yaml.v2"
version = "2.2.1"
+[[constraint]]
+ name = "livingit.de/code/go-hookhelper"
+ version = "0.1.0"
+
[prune]
go-tests = true
unused-packages = true
diff --git a/README.md b/README.md
index 6b89cea..52d9c05 100644
--- a/README.md
+++ b/README.md
@@ -65,6 +65,7 @@ Essentially this just removes the hook, so it would remove any other hook also.
|Version|Description|
|---|---|
+|0.8.0|add support for Co-authored-by|
|0.7.0|rename binary|
|0.6.2|code quality improvements|
|0.6.1|code quality improvements|
diff --git a/hook/v2/validate_body.go b/hook/v2/validate_body.go
index f41a953..c7789c5 100644
--- a/hook/v2/validate_body.go
+++ b/hook/v2/validate_body.go
@@ -1,11 +1,18 @@
package v2
-import "fmt"
+import (
+ "fmt"
+ "strings"
+)
// validateBody runs all rules for a commit message body
func (cfg *Configuration) validateBody(commitMessage []string) bool {
result := true
for _, line := range commitMessage {
+ if strings.HasPrefix(line, "Co-authored-by") {
+ fmt.Println("Co-authored-by found, not checking line length")
+ continue
+ }
if len(line) > cfg.BodyLineLength {
if cfg.EnforceBodyLineLength {
result = false
diff --git a/hook/v2/validate_body_test.go b/hook/v2/validate_body_test.go
new file mode 100644
index 0000000..f2db558
--- /dev/null
+++ b/hook/v2/validate_body_test.go
@@ -0,0 +1,48 @@
+package v2
+
+import "testing"
+
+func TestLineLengthLastLine(t *testing.T) {
+ body := []string{
+ "this is a normal length line",
+ "01234567890123456789012345678901234567890123456789012345678901234567890123456789",
+ }
+ cfg := &Configuration{
+ BodyLineLength: 72,
+ EnforceBodyLineLength: true,
+ }
+ if cfg.validateBody(body) {
+ t.Log("line is too long, validation did not get it")
+ t.Fail()
+ }
+}
+
+func TestLineLengthFirstLine(t *testing.T) {
+ body := []string{
+ "01234567890123456789012345678901234567890123456789012345678901234567890123456789",
+ "this is a normal length line",
+ }
+ cfg := &Configuration{
+ BodyLineLength: 72,
+ EnforceBodyLineLength: true,
+ }
+ if cfg.validateBody(body) {
+ t.Log("line is too long, validation did not get it")
+ t.Fail()
+ }
+}
+
+func TestLineLengthCoAuthored(t *testing.T) {
+ body := []string{
+ "this is a normal length line",
+ "Co-authored-by: This is the name ",
+ }
+ cfg := &Configuration{
+ BodyLineLength: 72,
+ EnforceBodyLineLength: true,
+ }
+ if !cfg.validateBody(body) {
+ t.Log("co-authored lines should not be enforced to be max characters long")
+ t.Fail()
+ }
+}
diff --git a/vendor/livingit.de/code/go-hookhelper/README.md b/vendor/livingit.de/code/go-hookhelper/README.md
new file mode 100644
index 0000000..026800e
--- /dev/null
+++ b/vendor/livingit.de/code/go-hookhelper/README.md
@@ -0,0 +1,9 @@
+# helper methods for git-hook projects
+
+some common helper methods used across git hook projects
+
+## History
+
+|Version|Description|
+|---|---|
+|0.1.0|Initial version|
\ No newline at end of file
diff --git a/vendor/livingit.de/code/go-hookhelper/optimistic_version.go b/vendor/livingit.de/code/go-hookhelper/optimistic_version.go
new file mode 100644
index 0000000..cde4d68
--- /dev/null
+++ b/vendor/livingit.de/code/go-hookhelper/optimistic_version.go
@@ -0,0 +1,24 @@
+package hookhelper
+
+import "errors"
+
+// OptimisticVersion returns the calculated optimistic version
+func OptimisticVersion(global, local []byte, globalVersion, localVersion string) (string, error) {
+ if nil != global {
+ if nil != local && localVersion != "" {
+ if localVersion == globalVersion && globalVersion == "" {
+ return "", errors.New("you have to provide versions for global and local config")
+ }
+ if localVersion != globalVersion {
+ return "", errors.New("version mismatch for global and project version")
+ }
+ }
+ return globalVersion, nil
+ }
+
+ if nil != local {
+ return localVersion, nil
+ }
+
+ return "", errors.New("no suitable versioned configuration found")
+}