Skip to content

Commit

Permalink
Ignore invalid issue numbers in commit messages. Fixes go-gitea#2022 (g…
Browse files Browse the repository at this point in the history
  • Loading branch information
lafriks authored and appleboy committed Jul 13, 2017
1 parent 7d61834 commit b639fa1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions models/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func UpdateIssuesCommit(doer *User, repo *Repository, commits []*PushCommit) err

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

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

issue, err := GetIssueByRef(ref)
if err != nil {
if IsErrIssueNotExist(err) || err == errMissingIssueNumber {
if IsErrIssueNotExist(err) || err == errMissingIssueNumber || err == errInvalidIssueNumber {
continue
}
return err
Expand Down
2 changes: 1 addition & 1 deletion models/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func TestUpdateIssuesCommit(t *testing.T) {
CommitterName: "User Two",
AuthorEmail: "user4@example.com",
AuthorName: "User Four",
Message: "start working on #1",
Message: "start working on #FST-1, #1",
},
{
Sha1: "abcdef2",
Expand Down
3 changes: 2 additions & 1 deletion models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

var (
errMissingIssueNumber = errors.New("No issue number specified")
errInvalidIssueNumber = errors.New("Invalid issue number")
)

// Issue represents an issue or pull request of repository.
Expand Down Expand Up @@ -961,7 +962,7 @@ func GetIssueByRef(ref string) (*Issue, error) {

index, err := com.StrTo(ref[n+1:]).Int64()
if err != nil {
return nil, err
return nil, errInvalidIssueNumber
}

repo, err := GetRepositoryByRef(ref[:n])
Expand Down

0 comments on commit b639fa1

Please sign in to comment.