From ed4791411a81543bdae70dec9715b8cb4687f6ec Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Fri, 14 Jun 2019 17:55:49 +0100 Subject: [PATCH 1/2] Allow colon between fixing word and issue --- models/action.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/action.go b/models/action.go index b4f4b1cb6d0ef..ee5d052509337 100644 --- a/models/action.go +++ b/models/action.go @@ -67,7 +67,7 @@ var ( const issueRefRegexpStr = `(?:([0-9a-zA-Z-_\.]+)/([0-9a-zA-Z-_\.]+))?(#[0-9]+)+` func assembleKeywordsPattern(words []string) string { - return fmt.Sprintf(`(?i)(?:%s) %s`, strings.Join(words, "|"), issueRefRegexpStr) + return fmt.Sprintf(`(?i)(?:%s)(?::?) %s`, strings.Join(words, "|"), issueRefRegexpStr) } func init() { From f10802143f1a8a34d10ce7b80fd1902c43eba749 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Fri, 14 Jun 2019 19:39:10 +0100 Subject: [PATCH 2/2] update test --- models/action_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/models/action_test.go b/models/action_test.go index 9ba205731835b..53a3202894e2e 100644 --- a/models/action_test.go +++ b/models/action_test.go @@ -166,6 +166,7 @@ func Test_getIssueFromRef(t *testing.T) { {"reopen #2", 2}, {"user2/repo2#1", 4}, {"fixes user2/repo2#1", 4}, + {"fixes: user2/repo2#1", 4}, } { issue, err := getIssueFromRef(repo, test.Ref) assert.NoError(t, err) @@ -260,6 +261,31 @@ func TestUpdateIssuesCommit(t *testing.T) { CheckConsistencyFor(t, &Action{}) } +func TestUpdateIssuesCommit_Colon(t *testing.T) { + assert.NoError(t, PrepareTestDatabase()) + pushCommits := []*PushCommit{ + { + Sha1: "abcdef2", + CommitterEmail: "user2@example.com", + CommitterName: "User Two", + AuthorEmail: "user2@example.com", + AuthorName: "User Two", + Message: "close: #2", + }, + } + + user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User) + repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository) + repo.Owner = user + + issueBean := &Issue{RepoID: repo.ID, Index: 2} + + AssertNotExistsBean(t, &Issue{RepoID: repo.ID, Index: 2}, "is_closed=1") + assert.NoError(t, UpdateIssuesCommit(user, repo, pushCommits, repo.DefaultBranch)) + AssertExistsAndLoadBean(t, issueBean, "is_closed=1") + CheckConsistencyFor(t, &Action{}) +} + func TestUpdateIssuesCommit_Issue5957(t *testing.T) { assert.NoError(t, PrepareTestDatabase()) user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)