Skip to content

Commit d296520

Browse files
committed
improve
1 parent 6364056 commit d296520

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

services/pull/merge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func AddCommitMessageTailer(message, tailerKey, tailerValue string) string {
186186
lastLineKey = message[pos1+1 : pos2]
187187
}
188188

189-
isLikelyTailerLine := lastLineKey != "" && unicode.IsUpper(rune(lastLineKey[0]))
189+
isLikelyTailerLine := lastLineKey != "" && unicode.IsUpper(rune(lastLineKey[0])) && strings.Contains(message, "-")
190190
for i := 0; isLikelyTailerLine && i < len(lastLineKey); i++ {
191191
r := rune(lastLineKey[i])
192192
isLikelyTailerLine = unicode.IsLetter(r) || unicode.IsDigit(r) || r == '-'

services/pull/merge_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ func TestAddCommitMessageTailer(t *testing.T) {
7272

7373
// add tailer for message without newlines
7474
assert.Equal(t, "title\n\nTest-tailer: TestValue", AddCommitMessageTailer("title", "Test-tailer", "TestValue"))
75-
assert.Equal(t, "title\n\nnot tailer: xxx\n\nTest-tailer: TestValue", AddCommitMessageTailer("title\n\nnot tailer: xxx", "Test-tailer", "TestValue"))
75+
assert.Equal(t, "title\n\nNot tailer: xxx\n\nTest-tailer: TestValue", AddCommitMessageTailer("title\n\nNot tailer: xxx", "Test-tailer", "TestValue"))
76+
assert.Equal(t, "title\n\nNotTailer: xxx\n\nTest-tailer: TestValue", AddCommitMessageTailer("title\n\nNotTailer: xxx", "Test-tailer", "TestValue"))
77+
assert.Equal(t, "title\n\nnot-tailer: xxx\n\nTest-tailer: TestValue", AddCommitMessageTailer("title\n\nnot-tailer: xxx", "Test-tailer", "TestValue"))
7678

7779
// add tailer for message with one EOL
7880
assert.Equal(t, "title\n\nTest-tailer: TestValue", AddCommitMessageTailer("title\n", "Test-tailer", "TestValue"))

0 commit comments

Comments
 (0)