Properly enforce gitea environment for pushes (#9501)

#8982 attempted to enforce the gitea environment for pushes - unfortunately it tested the settings before they were actually read in - and therefore does not do that!
This commit is contained in:
zeripath 2019-12-27 21:15:04 +00:00 committed by GitHub
parent f2d03cda96
commit 4acca9d2e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 8 deletions

View file

@ -242,10 +242,19 @@ func PushToBaseRepo(pr *models.PullRequest) (err error) {
_ = os.Remove(file)
if err = pr.LoadIssue(); err != nil {
return fmt.Errorf("unable to load issue %d for pr %d: %v", pr.IssueID, pr.ID, err)
}
if err = pr.Issue.LoadPoster(); err != nil {
return fmt.Errorf("unable to load poster %d for pr %d: %v", pr.Issue.PosterID, pr.ID, err)
}
if err = git.Push(headRepoPath, git.PushOptions{
Remote: tmpRemoteName,
Branch: fmt.Sprintf("%s:%s", pr.HeadBranch, headFile),
Force: true,
// Use InternalPushingEnvironment here because we know that pre-receive and post-receive do not run on a refs/pulls/...
Env: models.InternalPushingEnvironment(pr.Issue.Poster, pr.BaseRepo),
}); err != nil {
return fmt.Errorf("Push: %v", err)
}