Skip to content

Commit 94ceaf1

Browse files
zeripathtechknowlogick
authored andcommitted
Allow colon between fixing word and issue (#7207)
* Allow colon between fixing word and issue * update test
1 parent 9ce4d89 commit 94ceaf1

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

models/action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ var (
6767
const issueRefRegexpStr = `(?:([0-9a-zA-Z-_\.]+)/([0-9a-zA-Z-_\.]+))?(#[0-9]+)+`
6868

6969
func assembleKeywordsPattern(words []string) string {
70-
return fmt.Sprintf(`(?i)(?:%s) %s`, strings.Join(words, "|"), issueRefRegexpStr)
70+
return fmt.Sprintf(`(?i)(?:%s)(?::?) %s`, strings.Join(words, "|"), issueRefRegexpStr)
7171
}
7272

7373
func init() {

models/action_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ func Test_getIssueFromRef(t *testing.T) {
166166
{"reopen #2", 2},
167167
{"user2/repo2#1", 4},
168168
{"fixes user2/repo2#1", 4},
169+
{"fixes: user2/repo2#1", 4},
169170
} {
170171
issue, err := getIssueFromRef(repo, test.Ref)
171172
assert.NoError(t, err)
@@ -260,6 +261,31 @@ func TestUpdateIssuesCommit(t *testing.T) {
260261
CheckConsistencyFor(t, &Action{})
261262
}
262263

264+
func TestUpdateIssuesCommit_Colon(t *testing.T) {
265+
assert.NoError(t, PrepareTestDatabase())
266+
pushCommits := []*PushCommit{
267+
{
268+
Sha1: "abcdef2",
269+
CommitterEmail: "[email protected]",
270+
CommitterName: "User Two",
271+
AuthorEmail: "[email protected]",
272+
AuthorName: "User Two",
273+
Message: "close: #2",
274+
},
275+
}
276+
277+
user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
278+
repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
279+
repo.Owner = user
280+
281+
issueBean := &Issue{RepoID: repo.ID, Index: 2}
282+
283+
AssertNotExistsBean(t, &Issue{RepoID: repo.ID, Index: 2}, "is_closed=1")
284+
assert.NoError(t, UpdateIssuesCommit(user, repo, pushCommits, repo.DefaultBranch))
285+
AssertExistsAndLoadBean(t, issueBean, "is_closed=1")
286+
CheckConsistencyFor(t, &Action{})
287+
}
288+
263289
func TestUpdateIssuesCommit_Issue5957(t *testing.T) {
264290
assert.NoError(t, PrepareTestDatabase())
265291
user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)

0 commit comments

Comments
 (0)