diff options
author | zeripath <art27@cantab.net> | 2019-06-15 05:00:32 +0100 |
---|---|---|
committer | techknowlogick <hello@techknowlogick.com> | 2019-06-15 00:00:32 -0400 |
commit | 94ceaf1c0c2ae0b5abcb3b62c5c903258659615c (patch) | |
tree | d40dd10cc0ac1791c5377633dba9d59cf047c8ca | |
parent | 9ce4d89e9922cc87bdb13d122339ae165a080c3d (diff) | |
download | gitea-94ceaf1c0c2ae0b5abcb3b62c5c903258659615c.tar.gz gitea-94ceaf1c0c2ae0b5abcb3b62c5c903258659615c.zip |
Allow colon between fixing word and issue (#7207)
* Allow colon between fixing word and issue
* update test
-rw-r--r-- | models/action.go | 2 | ||||
-rw-r--r-- | models/action_test.go | 26 |
2 files changed, 27 insertions, 1 deletions
diff --git a/models/action.go b/models/action.go index b4f4b1cb6d..ee5d052509 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() { diff --git a/models/action_test.go b/models/action_test.go index 9ba2057318..53a3202894 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) |