models/action: skip issue index parsing while using external issue tracker (#5551)

This commit is contained in:
Unknwon 2018-12-17 22:52:58 -05:00
parent c82ac420fc
commit d74437af57
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
4 changed files with 13 additions and 15 deletions

View File

@ -16,7 +16,7 @@ import (
"github.com/gogs/gogs/pkg/setting" "github.com/gogs/gogs/pkg/setting"
) )
const APP_VER = "0.11.80.1216" const APP_VER = "0.11.81.1217"
func init() { func init() {
setting.AppVer = APP_VER setting.AppVer = APP_VER

View File

@ -58,20 +58,15 @@ var (
IssueCloseKeywords = []string{"close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved"} IssueCloseKeywords = []string{"close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved"}
IssueReopenKeywords = []string{"reopen", "reopens", "reopened"} IssueReopenKeywords = []string{"reopen", "reopens", "reopened"}
IssueCloseKeywordsPat, IssueReopenKeywordsPat *regexp.Regexp IssueCloseKeywordsPat = regexp.MustCompile(assembleKeywordsPattern(IssueCloseKeywords))
IssueReferenceKeywordsPat *regexp.Regexp IssueReopenKeywordsPat = regexp.MustCompile(assembleKeywordsPattern(IssueReopenKeywords))
IssueReferenceKeywordsPat = regexp.MustCompile(`(?i)(?:)(^| )\S+`)
) )
func assembleKeywordsPattern(words []string) string { func assembleKeywordsPattern(words []string) string {
return fmt.Sprintf(`(?i)(?:%s) \S+`, strings.Join(words, "|")) 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, // Action represents user operation type and other information to repository,
// it implemented interface base.Actioner so that can be used in template render. // it implemented interface base.Actioner so that can be used in template render.
type Action struct { type Action struct {
@ -492,10 +487,13 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
opts.Commits.CompareURL = repo.ComposeCompareURL(opts.OldCommitID, opts.NewCommitID) opts.Commits.CompareURL = repo.ComposeCompareURL(opts.OldCommitID, opts.NewCommitID)
} }
// 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 { if err = UpdateIssuesCommit(pusher, repo, opts.Commits.Commits); err != nil {
log.Error(2, "UpdateIssuesCommit: %v", err) log.Error(2, "UpdateIssuesCommit: %v", err)
} }
} }
}
if len(opts.Commits.Commits) > setting.UI.FeedMaxCommitNum { if len(opts.Commits.Commits) > setting.UI.FeedMaxCommitNum {
opts.Commits.Commits = opts.Commits.Commits[:setting.UI.FeedMaxCommitNum] opts.Commits.Commits = opts.Commits.Commits[:setting.UI.FeedMaxCommitNum]

View File

@ -804,9 +804,9 @@ func GetIssueByRef(ref string) (*Issue, error) {
return nil, errors.InvalidIssueReference{ref} return nil, errors.InvalidIssueReference{ref}
} }
index, err := com.StrTo(ref[n+1:]).Int64() index := com.StrTo(ref[n+1:]).MustInt64()
if err != nil { if index == 0 {
return nil, err return nil, errors.IssueNotExist{}
} }
repo, err := GetRepositoryByRef(ref[:n]) repo, err := GetRepositoryByRef(ref[:n])

View File

@ -1 +1 @@
0.11.80.1216 0.11.81.1217