Browse Source

Ignore invalid issue numbers in commit messages. Fixes #2022 (#2150)

for-closed-social
Lauris BH 7 years ago
committed by Bo-Yi Wu
parent
commit
b639fa1648
3 changed files with 6 additions and 5 deletions
  1. +3
    -3
      models/action.go
  2. +1
    -1
      models/action_test.go
  3. +2
    -1
      models/issue.go

+ 3
- 3
models/action.go View File

@ -424,7 +424,7 @@ func UpdateIssuesCommit(doer *User, repo *Repository, commits []*PushCommit) err
issue, err := GetIssueByRef(ref) issue, err := GetIssueByRef(ref)
if err != nil { if err != nil {
if IsErrIssueNotExist(err) || err == errMissingIssueNumber {
if IsErrIssueNotExist(err) || err == errMissingIssueNumber || err == errInvalidIssueNumber {
continue continue
} }
return err return err
@ -462,7 +462,7 @@ func UpdateIssuesCommit(doer *User, repo *Repository, commits []*PushCommit) err
issue, err := GetIssueByRef(ref) issue, err := GetIssueByRef(ref)
if err != nil { if err != nil {
if IsErrIssueNotExist(err) || err == errMissingIssueNumber {
if IsErrIssueNotExist(err) || err == errMissingIssueNumber || err == errInvalidIssueNumber {
continue continue
} }
return err return err
@ -502,7 +502,7 @@ func UpdateIssuesCommit(doer *User, repo *Repository, commits []*PushCommit) err
issue, err := GetIssueByRef(ref) issue, err := GetIssueByRef(ref)
if err != nil { if err != nil {
if IsErrIssueNotExist(err) || err == errMissingIssueNumber {
if IsErrIssueNotExist(err) || err == errMissingIssueNumber || err == errInvalidIssueNumber {
continue continue
} }
return err return err

+ 1
- 1
models/action_test.go View File

@ -161,7 +161,7 @@ func TestUpdateIssuesCommit(t *testing.T) {
CommitterName: "User Two", CommitterName: "User Two",
AuthorEmail: "user4@example.com", AuthorEmail: "user4@example.com",
AuthorName: "User Four", AuthorName: "User Four",
Message: "start working on #1",
Message: "start working on #FST-1, #1",
}, },
{ {
Sha1: "abcdef2", Sha1: "abcdef2",

+ 2
- 1
models/issue.go View File

@ -24,6 +24,7 @@ import (
var ( var (
errMissingIssueNumber = errors.New("No issue number specified") errMissingIssueNumber = errors.New("No issue number specified")
errInvalidIssueNumber = errors.New("Invalid issue number")
) )
// Issue represents an issue or pull request of repository. // Issue represents an issue or pull request of repository.
@ -961,7 +962,7 @@ func GetIssueByRef(ref string) (*Issue, error) {
index, err := com.StrTo(ref[n+1:]).Int64() index, err := com.StrTo(ref[n+1:]).Int64()
if err != nil { if err != nil {
return nil, err
return nil, errInvalidIssueNumber
} }
repo, err := GetRepositoryByRef(ref[:n]) repo, err := GetRepositoryByRef(ref[:n])

Loading…
Cancel
Save