refactored checkForInvalidation
Signed-off-by: Jonas Franz <info@jonasfranz.software>
This commit is contained in:
parent
ce07867db1
commit
dc4a27d109
|
@ -1162,25 +1162,9 @@ func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool
|
||||||
if err = requests.LoadAttributes(); err != nil {
|
if err = requests.LoadAttributes(); err != nil {
|
||||||
log.Error(4, "PullRequestList.LoadAttributes: %v", err)
|
log.Error(4, "PullRequestList.LoadAttributes: %v", err)
|
||||||
}
|
}
|
||||||
var gitRepo *git.Repository
|
if invalidationErr := checkForInvalidation(requests, repoID, doer, branch); invalidationErr != nil {
|
||||||
repo, err := GetRepositoryByID(repoID)
|
log.Error(4, "checkForInvalidation: %v", invalidationErr)
|
||||||
if err != nil {
|
|
||||||
log.Error(4, "GetRepositoryByID: %v", err)
|
|
||||||
goto REQUIRED_PROCEDURE
|
|
||||||
}
|
}
|
||||||
gitRepo, err = git.OpenRepository(repo.RepoPath())
|
|
||||||
if err != nil {
|
|
||||||
log.Error(4, "git.OpenRepository: %v", err)
|
|
||||||
goto REQUIRED_PROCEDURE
|
|
||||||
}
|
|
||||||
go func() {
|
|
||||||
err := requests.InvalidateCodeComments(doer, gitRepo, branch)
|
|
||||||
if err != nil {
|
|
||||||
log.Error(4, "PullRequestList.InvalidateCodeComments: %v", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
REQUIRED_PROCEDURE:
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _, pr := range prs {
|
for _, pr := range prs {
|
||||||
pr.Issue.PullRequest = pr
|
pr.Issue.PullRequest = pr
|
||||||
|
@ -1201,6 +1185,7 @@ func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool
|
||||||
go HookQueue.Add(pr.Issue.Repo.ID)
|
go HookQueue.Add(pr.Issue.Repo.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addHeadRepoTasks(prs)
|
addHeadRepoTasks(prs)
|
||||||
|
@ -1216,6 +1201,24 @@ func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkForInvalidation(requests PullRequestList, repoID int64, doer *User, branch string) error {
|
||||||
|
repo, err := GetRepositoryByID(repoID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("GetRepositoryByID: %v", err)
|
||||||
|
}
|
||||||
|
gitRepo, err := git.OpenRepository(repo.RepoPath())
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("git.OpenRepository: %v", err)
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
err := requests.InvalidateCodeComments(doer, gitRepo, branch)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(4, "PullRequestList.InvalidateCodeComments: %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// ChangeUsernameInPullRequests changes the name of head_user_name
|
// ChangeUsernameInPullRequests changes the name of head_user_name
|
||||||
func ChangeUsernameInPullRequests(oldUserName, newUserName string) error {
|
func ChangeUsernameInPullRequests(oldUserName, newUserName string) error {
|
||||||
pr := PullRequest{
|
pr := PullRequest{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user