mirror of
https://github.com/go-gitea/gitea
synced 2024-12-23 00:54:28 +00:00
Fix bug create/edit wiki pages when code master branch protected (#7580)
* fix bug create/edit wiki pages when code master branch protected * improve FullPushingEnvironment function
This commit is contained in:
parent
18c0e9c2a9
commit
6782a704ef
@ -12,13 +12,13 @@ import (
|
|||||||
|
|
||||||
// PushingEnvironment returns an os environment to allow hooks to work on push
|
// PushingEnvironment returns an os environment to allow hooks to work on push
|
||||||
func PushingEnvironment(doer *User, repo *Repository) []string {
|
func PushingEnvironment(doer *User, repo *Repository) []string {
|
||||||
return FullPushingEnvironment(doer, doer, repo, 0)
|
return FullPushingEnvironment(doer, doer, repo, repo.Name, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FullPushingEnvironment returns an os environment to allow hooks to work on push
|
// FullPushingEnvironment returns an os environment to allow hooks to work on push
|
||||||
func FullPushingEnvironment(author, committer *User, repo *Repository, prID int64) []string {
|
func FullPushingEnvironment(author, committer *User, repo *Repository, repoName string, prID int64) []string {
|
||||||
isWiki := "false"
|
isWiki := "false"
|
||||||
if strings.HasSuffix(repo.Name, ".wiki") {
|
if strings.HasSuffix(repoName, ".wiki") {
|
||||||
isWiki = "true"
|
isWiki = "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ func FullPushingEnvironment(author, committer *User, repo *Repository, prID int6
|
|||||||
"GIT_AUTHOR_EMAIL="+authorSig.Email,
|
"GIT_AUTHOR_EMAIL="+authorSig.Email,
|
||||||
"GIT_COMMITTER_NAME="+committerSig.Name,
|
"GIT_COMMITTER_NAME="+committerSig.Name,
|
||||||
"GIT_COMMITTER_EMAIL="+committerSig.Email,
|
"GIT_COMMITTER_EMAIL="+committerSig.Email,
|
||||||
EnvRepoName+"="+repo.Name,
|
EnvRepoName+"="+repoName,
|
||||||
EnvRepoUsername+"="+repo.MustOwnerName(),
|
EnvRepoUsername+"="+repo.MustOwnerName(),
|
||||||
EnvRepoIsWiki+"="+isWiki,
|
EnvRepoIsWiki+"="+isWiki,
|
||||||
EnvPusherName+"="+committer.Name,
|
EnvPusherName+"="+committer.Name,
|
||||||
|
@ -217,7 +217,13 @@ func (repo *Repository) updateWikiPage(doer *User, oldWikiName, newWikiName, con
|
|||||||
if err := git.Push(basePath, git.PushOptions{
|
if err := git.Push(basePath, git.PushOptions{
|
||||||
Remote: "origin",
|
Remote: "origin",
|
||||||
Branch: fmt.Sprintf("%s:%s%s", commitHash.String(), git.BranchPrefix, "master"),
|
Branch: fmt.Sprintf("%s:%s%s", commitHash.String(), git.BranchPrefix, "master"),
|
||||||
Env: PushingEnvironment(doer, repo),
|
Env: FullPushingEnvironment(
|
||||||
|
doer,
|
||||||
|
doer,
|
||||||
|
repo,
|
||||||
|
repo.Name+".wiki",
|
||||||
|
0,
|
||||||
|
),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error("%v", err)
|
log.Error("%v", err)
|
||||||
return fmt.Errorf("Push: %v", err)
|
return fmt.Errorf("Push: %v", err)
|
||||||
|
@ -240,7 +240,13 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor
|
|||||||
headUser = doer
|
headUser = doer
|
||||||
}
|
}
|
||||||
|
|
||||||
env := models.FullPushingEnvironment(headUser, doer, pr.BaseRepo, pr.ID)
|
env := models.FullPushingEnvironment(
|
||||||
|
headUser,
|
||||||
|
doer,
|
||||||
|
pr.BaseRepo,
|
||||||
|
pr.BaseRepo.Name,
|
||||||
|
pr.ID,
|
||||||
|
)
|
||||||
|
|
||||||
// Push back to upstream.
|
// Push back to upstream.
|
||||||
if err := git.NewCommand("push", "origin", pr.BaseBranch).RunInDirTimeoutEnvPipeline(env, -1, tmpBasePath, nil, &errbuf); err != nil {
|
if err := git.NewCommand("push", "origin", pr.BaseBranch).RunInDirTimeoutEnvPipeline(env, -1, tmpBasePath, nil, &errbuf); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user