diff options
author | Unknwon <u@gogs.io> | 2018-12-17 22:52:58 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2018-12-17 22:52:58 -0500 |
commit | d74437af578718784c30819f160dc98e6f401a12 (patch) | |
tree | 6f9a70e6169154f266d1053832904b8bcd2d95a6 /models | |
parent | c82ac420fc86f454700f9f6e6148ed27a6f185cd (diff) |
models/action: skip issue index parsing while using external issue tracker (#5551)
Diffstat (limited to 'models')
-rw-r--r-- | models/action.go | 18 | ||||
-rw-r--r-- | models/issue.go | 6 |
2 files changed, 11 insertions, 13 deletions
diff --git a/models/action.go b/models/action.go index 61c6afc3..7d196652 100644 --- a/models/action.go +++ b/models/action.go @@ -58,20 +58,15 @@ var ( IssueCloseKeywords = []string{"close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved"} IssueReopenKeywords = []string{"reopen", "reopens", "reopened"} - IssueCloseKeywordsPat, IssueReopenKeywordsPat *regexp.Regexp - IssueReferenceKeywordsPat *regexp.Regexp + IssueCloseKeywordsPat = regexp.MustCompile(assembleKeywordsPattern(IssueCloseKeywords)) + IssueReopenKeywordsPat = regexp.MustCompile(assembleKeywordsPattern(IssueReopenKeywords)) + IssueReferenceKeywordsPat = regexp.MustCompile(`(?i)(?:)(^| )\S+`) ) func assembleKeywordsPattern(words []string) string { return fmt.Sprintf(`(?i)(?:%s) \S+`, strings.Join(words, "|")) } -func init() { - IssueCloseKeywordsPat = regexp.MustCompile(assembleKeywordsPattern(IssueCloseKeywords)) - IssueReopenKeywordsPat = regexp.MustCompile(assembleKeywordsPattern(IssueReopenKeywords)) - IssueReferenceKeywordsPat = regexp.MustCompile(`(?i)(?:)(^| )\S+`) -} - // Action represents user operation type and other information to repository, // it implemented interface base.Actioner so that can be used in template render. type Action struct { @@ -492,8 +487,11 @@ func CommitRepoAction(opts CommitRepoActionOptions) error { opts.Commits.CompareURL = repo.ComposeCompareURL(opts.OldCommitID, opts.NewCommitID) } - if err = UpdateIssuesCommit(pusher, repo, opts.Commits.Commits); err != nil { - log.Error(2, "UpdateIssuesCommit: %v", err) + // Only update issues via commits when internal issue tracker is enabled + if repo.EnableIssues && !repo.EnableExternalTracker { + if err = UpdateIssuesCommit(pusher, repo, opts.Commits.Commits); err != nil { + log.Error(2, "UpdateIssuesCommit: %v", err) + } } } diff --git a/models/issue.go b/models/issue.go index 195c0cf9..64c70744 100644 --- a/models/issue.go +++ b/models/issue.go @@ -804,9 +804,9 @@ func GetIssueByRef(ref string) (*Issue, error) { return nil, errors.InvalidIssueReference{ref} } - index, err := com.StrTo(ref[n+1:]).Int64() - if err != nil { - return nil, err + index := com.StrTo(ref[n+1:]).MustInt64() + if index == 0 { + return nil, errors.IssueNotExist{} } repo, err := GetRepositoryByRef(ref[:n]) |