mirror of https://github.com/gogs/gogs.git
models/repo_editor: add pull request test task after commit (#4338)
parent
260ebcc1ca
commit
8f52ab8201
2
gogs.go
2
gogs.go
|
@ -16,7 +16,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.10.30.0324"
|
const APP_VER = "0.10.30.0325"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
setting.AppVer = APP_VER
|
setting.AppVer = APP_VER
|
||||||
|
|
|
@ -607,7 +607,7 @@ func (pr *PullRequest) AddToTaskQueue() {
|
||||||
go PullRequestQueue.AddFunc(pr.ID, func() {
|
go PullRequestQueue.AddFunc(pr.ID, func() {
|
||||||
pr.Status = PULL_REQUEST_STATUS_CHECKING
|
pr.Status = PULL_REQUEST_STATUS_CHECKING
|
||||||
if err := pr.UpdateCols("status"); err != nil {
|
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)
|
log.Trace("AddTestPullRequestTask [head_repo_id: %d, head_branch: %s]: finding pull requests", repoID, branch)
|
||||||
prs, err := GetUnmergedPullRequestsByHeadInfo(repoID, branch)
|
prs, err := GetUnmergedPullRequestsByHeadInfo(repoID, branch)
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if isSync {
|
if isSync {
|
||||||
if err = PullRequestList(prs).LoadAttributes(); err != nil {
|
if err = PullRequestList(prs).LoadAttributes(); err != nil {
|
||||||
log.Error(4, "PullRequestList.LoadAttributes: %v", err)
|
log.Error(2, "PullRequestList.LoadAttributes: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _, pr := range prs {
|
for _, pr := range prs {
|
||||||
pr.Issue.PullRequest = pr
|
pr.Issue.PullRequest = pr
|
||||||
if err = pr.Issue.LoadAttributes(); err != nil {
|
if err = pr.Issue.LoadAttributes(); err != nil {
|
||||||
log.Error(4, "LoadAttributes: %v", err)
|
log.Error(2, "LoadAttributes: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err = PrepareWebhooks(pr.Issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
|
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),
|
Repository: pr.Issue.Repo.APIFormat(nil),
|
||||||
Sender: doer.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
}); err != nil {
|
}); 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
|
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)
|
log.Trace("AddTestPullRequestTask [base_repo_id: %d, base_branch: %s]: finding pull requests", repoID, branch)
|
||||||
prs, err = GetUnmergedPullRequestsByBaseInfo(repoID, branch)
|
prs, err = GetUnmergedPullRequestsByBaseInfo(repoID, branch)
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
for _, pr := range prs {
|
for _, pr := range prs {
|
||||||
|
|
|
@ -135,12 +135,12 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
|
||||||
|
|
||||||
gitRepo, err := git.OpenRepository(repo.RepoPath())
|
gitRepo, err := git.OpenRepository(repo.RepoPath())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(4, "OpenRepository: %v", err)
|
log.Error(2, "OpenRepository: %v", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
commit, err := gitRepo.GetBranchCommit(opts.NewBranch)
|
commit, err := gitRepo.GetBranchCommit(opts.NewBranch)
|
||||||
if err != nil {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,10 +162,11 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
|
||||||
NewCommitID: commit.ID.String(),
|
NewCommitID: commit.ID.String(),
|
||||||
Commits: pushCommits,
|
Commits: pushCommits,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error(4, "CommitRepoAction: %v", err)
|
log.Error(2, "CommitRepoAction: %v", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
go AddTestPullRequestTask(doer, repo.ID, opts.NewBranch, true)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,12 +266,12 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (
|
||||||
|
|
||||||
gitRepo, err := git.OpenRepository(repo.RepoPath())
|
gitRepo, err := git.OpenRepository(repo.RepoPath())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(4, "OpenRepository: %v", err)
|
log.Error(2, "OpenRepository: %v", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
commit, err := gitRepo.GetBranchCommit(opts.NewBranch)
|
commit, err := gitRepo.GetBranchCommit(opts.NewBranch)
|
||||||
if err != nil {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,10 +289,11 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (
|
||||||
NewCommitID: commit.ID.String(),
|
NewCommitID: commit.ID.String(),
|
||||||
Commits: pushCommits,
|
Commits: pushCommits,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error(4, "CommitRepoAction: %v", err)
|
log.Error(2, "CommitRepoAction: %v", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
go AddTestPullRequestTask(doer, repo.ID, opts.NewBranch, true)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,12 +491,12 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions)
|
||||||
|
|
||||||
gitRepo, err := git.OpenRepository(repo.RepoPath())
|
gitRepo, err := git.OpenRepository(repo.RepoPath())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(4, "OpenRepository: %v", err)
|
log.Error(2, "OpenRepository: %v", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
commit, err := gitRepo.GetBranchCommit(opts.NewBranch)
|
commit, err := gitRepo.GetBranchCommit(opts.NewBranch)
|
||||||
if err != nil {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,9 +514,10 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions)
|
||||||
NewCommitID: commit.ID.String(),
|
NewCommitID: commit.ID.String(),
|
||||||
Commits: pushCommits,
|
Commits: pushCommits,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error(4, "CommitRepoAction: %v", err)
|
log.Error(2, "CommitRepoAction: %v", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
go AddTestPullRequestTask(doer, repo.ID, opts.NewBranch, true)
|
||||||
return DeleteUploads(uploads...)
|
return DeleteUploads(uploads...)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
// It's safe to fail when the whole function is called during hook execution
|
||||||
// because resource released after exit.
|
// because resource released after exit. Also, there is no process started to
|
||||||
// FIXME: need a more safe way to not call this function if it's during hook execution.
|
// consume this input during hook execution.
|
||||||
go HookQueue.Add(repo.ID)
|
go HookQueue.Add(repo.ID)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.10.30.0324
|
0.10.30.0325
|
Loading…
Reference in New Issue