From 8f52ab820106aac86fa5985bb5ba3ecc22b58725 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sat, 25 Mar 2017 03:36:13 -0400 Subject: [PATCH] models/repo_editor: add pull request test task after commit (#4338) --- gogs.go | 2 +- models/pull.go | 13 ++++++------- models/repo_editor.go | 21 ++++++++++++--------- models/webhook.go | 4 ++-- templates/.VERSION | 2 +- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/gogs.go b/gogs.go index 301bfb456..99d365baa 100644 --- a/gogs.go +++ b/gogs.go @@ -16,7 +16,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.10.30.0324" +const APP_VER = "0.10.30.0325" func init() { setting.AppVer = APP_VER diff --git a/models/pull.go b/models/pull.go index d7a8e36fb..f46d69fcb 100644 --- a/models/pull.go +++ b/models/pull.go @@ -607,7 +607,7 @@ func (pr *PullRequest) AddToTaskQueue() { go PullRequestQueue.AddFunc(pr.ID, func() { pr.Status = PULL_REQUEST_STATUS_CHECKING if err := pr.UpdateCols("status"); err != nil { - log.Error(5, "AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err) + log.Error(3, "AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err) } }) } @@ -674,20 +674,20 @@ func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool log.Trace("AddTestPullRequestTask [head_repo_id: %d, head_branch: %s]: finding pull requests", repoID, branch) prs, err := GetUnmergedPullRequestsByHeadInfo(repoID, branch) if err != nil { - log.Error(4, "Find pull requests [head_repo_id: %d, head_branch: %s]: %v", repoID, branch, err) + log.Error(2, "Find pull requests [head_repo_id: %d, head_branch: %s]: %v", repoID, branch, err) return } if isSync { if err = PullRequestList(prs).LoadAttributes(); err != nil { - log.Error(4, "PullRequestList.LoadAttributes: %v", err) + log.Error(2, "PullRequestList.LoadAttributes: %v", err) } if err == nil { for _, pr := range prs { pr.Issue.PullRequest = pr if err = pr.Issue.LoadAttributes(); err != nil { - log.Error(4, "LoadAttributes: %v", err) + log.Error(2, "LoadAttributes: %v", err) continue } if err = PrepareWebhooks(pr.Issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{ @@ -697,10 +697,9 @@ func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool Repository: pr.Issue.Repo.APIFormat(nil), Sender: doer.APIFormat(), }); err != nil { - log.Error(4, "PrepareWebhooks [pull_id: %v]: %v", pr.ID, err) + log.Error(2, "PrepareWebhooks [pull_id: %v]: %v", pr.ID, err) continue } - go HookQueue.Add(pr.Issue.Repo.ID) } } } @@ -710,7 +709,7 @@ func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool log.Trace("AddTestPullRequestTask [base_repo_id: %d, base_branch: %s]: finding pull requests", repoID, branch) prs, err = GetUnmergedPullRequestsByBaseInfo(repoID, branch) if err != nil { - log.Error(4, "Find pull requests [base_repo_id: %d, base_branch: %s]: %v", repoID, branch, err) + log.Error(2, "Find pull requests [base_repo_id: %d, base_branch: %s]: %v", repoID, branch, err) return } for _, pr := range prs { diff --git a/models/repo_editor.go b/models/repo_editor.go index 966502049..a9990c992 100644 --- a/models/repo_editor.go +++ b/models/repo_editor.go @@ -135,12 +135,12 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) ( gitRepo, err := git.OpenRepository(repo.RepoPath()) if err != nil { - log.Error(4, "OpenRepository: %v", err) + log.Error(2, "OpenRepository: %v", err) return nil } commit, err := gitRepo.GetBranchCommit(opts.NewBranch) if err != nil { - log.Error(4, "GetBranchCommit [branch: %s]: %v", opts.NewBranch, err) + log.Error(2, "GetBranchCommit [branch: %s]: %v", opts.NewBranch, err) return nil } @@ -162,10 +162,11 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) ( NewCommitID: commit.ID.String(), Commits: pushCommits, }); err != nil { - log.Error(4, "CommitRepoAction: %v", err) + log.Error(2, "CommitRepoAction: %v", err) return nil } + go AddTestPullRequestTask(doer, repo.ID, opts.NewBranch, true) return nil } @@ -265,12 +266,12 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) ( gitRepo, err := git.OpenRepository(repo.RepoPath()) if err != nil { - log.Error(4, "OpenRepository: %v", err) + log.Error(2, "OpenRepository: %v", err) return nil } commit, err := gitRepo.GetBranchCommit(opts.NewBranch) if err != nil { - log.Error(4, "GetBranchCommit [branch: %s]: %v", opts.NewBranch, err) + log.Error(2, "GetBranchCommit [branch: %s]: %v", opts.NewBranch, err) return nil } @@ -288,10 +289,11 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) ( NewCommitID: commit.ID.String(), Commits: pushCommits, }); err != nil { - log.Error(4, "CommitRepoAction: %v", err) + log.Error(2, "CommitRepoAction: %v", err) return nil } + go AddTestPullRequestTask(doer, repo.ID, opts.NewBranch, true) return nil } @@ -489,12 +491,12 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions) gitRepo, err := git.OpenRepository(repo.RepoPath()) if err != nil { - log.Error(4, "OpenRepository: %v", err) + log.Error(2, "OpenRepository: %v", err) return nil } commit, err := gitRepo.GetBranchCommit(opts.NewBranch) if err != nil { - log.Error(4, "GetBranchCommit [branch: %s]: %v", opts.NewBranch, err) + log.Error(2, "GetBranchCommit [branch: %s]: %v", opts.NewBranch, err) return nil } @@ -512,9 +514,10 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions) NewCommitID: commit.ID.String(), Commits: pushCommits, }); err != nil { - log.Error(4, "CommitRepoAction: %v", err) + log.Error(2, "CommitRepoAction: %v", err) return nil } + go AddTestPullRequestTask(doer, repo.ID, opts.NewBranch, true) return DeleteUploads(uploads...) } diff --git a/models/webhook.go b/models/webhook.go index 19f2ae18e..a1f8c343e 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -602,8 +602,8 @@ func prepareHookTasks(e Engine, repo *Repository, event HookEventType, p api.Pay } // It's safe to fail when the whole function is called during hook execution - // because resource released after exit. - // FIXME: need a more safe way to not call this function if it's during hook execution. + // because resource released after exit. Also, there is no process started to + // consume this input during hook execution. go HookQueue.Add(repo.ID) return nil } diff --git a/templates/.VERSION b/templates/.VERSION index 5ce571bf5..0e5097c0f 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.10.30.0324 \ No newline at end of file +0.10.30.0325 \ No newline at end of file