Просмотр исходного кода

skip issue index parsing while using external issue tracker

Yoginth 7 лет назад
Родитель
Сommit
73fe9529ed
2 измененных файлов с 12 добавлено и 15 удалено
  1. 9 12
      models/action.go
  2. 3 3
      models/issue.go

+ 9 - 12
models/action.go

@@ -59,20 +59,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 {
@@ -495,10 +490,12 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
 		if !isNewRef && !isDelRef {
 			opts.Commits.CompareURL = repo.ComposeCompareURL(opts.OldCommitID, opts.NewCommitID)
 		}
-
-		if err = UpdateIssuesCommit(pusher, repo, opts.Commits.Commits); err != nil {
-			raven.CaptureErrorAndWait(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 {
+				raven.CaptureErrorAndWait(err, nil)
+				log.Error(2, "UpdateIssuesCommit: %v", err)
+			}
 		}
 	}
 

+ 3 - 3
models/issue.go

@@ -813,11 +813,11 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string)
 // See https://help.github.com/articles/writing-on-github#references for more information on the syntax.
 func GetIssueByRef(ref string) (*Issue, error) {
 	n := strings.IndexByte(ref, byte('#'))
-	if n == -1 {
-		return nil, errors.InvalidIssueReference{ref}
+	if index == 0 {
+		return nil, errors.IssueNotExist{}
 	}
 
-	index, err := com.StrTo(ref[n+1:]).Int64()
+	index := com.StrTo(ref[n+1:]).MustInt64()
 	if err != nil {
 		return nil, err
 	}