Display pull request head branch even the branch deleted or repository deleted (#10413)
* Display pull request head branch even the branch deleted or repository deleted * Merge getHeadRepo/loadHeadRepo and getBaseRepo/loadBaseRepo on pull and fill repo when pr.Issue.Repo is available * retrieve sha from pull head when pull request branch deleted and fix tests * Fix test * Ensure MustHeadRepoName returns empty string if no head repo Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
parent
22b7507024
commit
5abe1c52de
12 changed files with 192 additions and 188 deletions
|
@ -236,16 +236,15 @@ func AddTestPullRequestTask(doer *models.User, repoID int64, branch string, isSy
|
|||
// checkIfPRContentChanged checks if diff to target branch has changed by push
|
||||
// A commit can be considered to leave the PR untouched if the patch/diff with its merge base is unchanged
|
||||
func checkIfPRContentChanged(pr *models.PullRequest, oldCommitID, newCommitID string) (hasChanged bool, err error) {
|
||||
|
||||
if err = pr.GetHeadRepo(); err != nil {
|
||||
return false, fmt.Errorf("GetHeadRepo: %v", err)
|
||||
if err = pr.LoadHeadRepo(); err != nil {
|
||||
return false, fmt.Errorf("LoadHeadRepo: %v", err)
|
||||
} else if pr.HeadRepo == nil {
|
||||
// corrupt data assumed changed
|
||||
return true, nil
|
||||
}
|
||||
|
||||
if err = pr.GetBaseRepo(); err != nil {
|
||||
return false, fmt.Errorf("GetBaseRepo: %v", err)
|
||||
if err = pr.LoadBaseRepo(); err != nil {
|
||||
return false, fmt.Errorf("LoadBaseRepo: %v", err)
|
||||
}
|
||||
|
||||
headGitRepo, err := git.OpenRepository(pr.HeadRepo.RepoPath())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue