mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-16 02:18:22 -07:00
Accept 'Data:' in commit graph (#4487)
This commit is contained in:
parent
5fa403c874
commit
bed623600d
@ -66,7 +66,7 @@ func graphItemFromString(s string, r *git.Repository) (GraphItem, error) {
|
|||||||
|
|
||||||
var ascii string
|
var ascii string
|
||||||
var data = "|||||||"
|
var data = "|||||||"
|
||||||
lines := strings.Split(s, "DATA:")
|
lines := strings.SplitN(s, "DATA:", 2)
|
||||||
|
|
||||||
switch len(lines) {
|
switch len(lines) {
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/git"
|
"code.gitea.io/git"
|
||||||
@ -43,3 +44,32 @@ func BenchmarkParseCommitString(b *testing.B) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCommitStringParsing(t *testing.T) {
|
||||||
|
dataFirstPart := "* DATA:||4e61bacab44e9b4730e44a6615d04098dd3a8eaf|2016-12-20 21:10:41 +0100|Author|user@mail.something|4e61bac|"
|
||||||
|
tests := []struct {
|
||||||
|
shouldPass bool
|
||||||
|
testName string
|
||||||
|
commitMessage string
|
||||||
|
}{
|
||||||
|
{true, "normal", "not a fancy message"},
|
||||||
|
{true, "extra pipe", "An extra pipe: |"},
|
||||||
|
{true, "extra 'Data:'", "DATA: might be trouble"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
|
||||||
|
t.Run(test.testName, func(t *testing.T) {
|
||||||
|
testString := fmt.Sprintf("%s%s", dataFirstPart, test.commitMessage)
|
||||||
|
graphItem, err := graphItemFromString(testString, nil)
|
||||||
|
if err != nil && test.shouldPass {
|
||||||
|
t.Errorf("Could not parse %s", testString)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if test.commitMessage != graphItem.Subject {
|
||||||
|
t.Errorf("%s does not match %s", test.commitMessage, graphItem.Subject)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user