mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
If you attempt to merge to a branch which on a PR there will be a nil pointer error in the pull request checker. This panic is uncaught and will bring down the gitea server. This PR adds protection to prevent this. Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
@@ -231,6 +231,10 @@ func PushToBaseRepo(pr *models.PullRequest) (err error) {
|
||||
}
|
||||
}()
|
||||
|
||||
if err := pr.LoadHeadRepo(); err != nil {
|
||||
log.Error("Unable to load head repository for PR[%d] Error: %v", pr.ID, err)
|
||||
return err
|
||||
}
|
||||
headRepoPath := pr.HeadRepo.RepoPath()
|
||||
|
||||
if err := git.Clone(headRepoPath, tmpBasePath, git.CloneRepoOptions{
|
||||
@@ -247,6 +251,10 @@ func PushToBaseRepo(pr *models.PullRequest) (err error) {
|
||||
return fmt.Errorf("OpenRepository: %v", err)
|
||||
}
|
||||
|
||||
if err := pr.LoadBaseRepo(); err != nil {
|
||||
log.Error("Unable to load base repository for PR[%d] Error: %v", pr.ID, err)
|
||||
return err
|
||||
}
|
||||
if err := gitRepo.AddRemote("base", pr.BaseRepo.RepoPath(), false); err != nil {
|
||||
return fmt.Errorf("tmpGitRepo.AddRemote: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user