Browse Source

Allow colon between fixing word and issue (#7207)

* Allow colon between fixing word and issue

* update test
tags/v1.9.0-rc1
zeripath 5 years ago
parent
commit
94ceaf1c0c
2 changed files with 27 additions and 1 deletions
  1. 1
    1
      models/action.go
  2. 26
    0
      models/action_test.go

+ 1
- 1
models/action.go View File

const issueRefRegexpStr = `(?:([0-9a-zA-Z-_\.]+)/([0-9a-zA-Z-_\.]+))?(#[0-9]+)+` const issueRefRegexpStr = `(?:([0-9a-zA-Z-_\.]+)/([0-9a-zA-Z-_\.]+))?(#[0-9]+)+`


func assembleKeywordsPattern(words []string) string { 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() { func init() {

+ 26
- 0
models/action_test.go View File

{"reopen #2", 2}, {"reopen #2", 2},
{"user2/repo2#1", 4}, {"user2/repo2#1", 4},
{"fixes user2/repo2#1", 4}, {"fixes user2/repo2#1", 4},
{"fixes: user2/repo2#1", 4},
} { } {
issue, err := getIssueFromRef(repo, test.Ref) issue, err := getIssueFromRef(repo, test.Ref)
assert.NoError(t, err) assert.NoError(t, err)
CheckConsistencyFor(t, &Action{}) 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) { func TestUpdateIssuesCommit_Issue5957(t *testing.T) {
assert.NoError(t, PrepareTestDatabase()) assert.NoError(t, PrepareTestDatabase())
user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User) user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)

Loading…
Cancel
Save