This repository has been archived by the owner on Jun 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <this-is-a-long@email-address-to-get-over71.de>", | ||
} | ||
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() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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| |
24 changes: 24 additions & 0 deletions
24
vendor/livingit.de/code/go-hookhelper/optimistic_version.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |