Skip to content

Commit 4c69e15

Browse files
lunnylafriks
authored andcommitted
Fix bug create/edit wiki pages when code master branch protected (#7580) (#7623)
* fix bug create/edit wiki pages when code master branch protected * improve FullPushingEnvironment function
1 parent b7e41f7 commit 4c69e15

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

Diff for: models/helper_environment.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import (
1212

1313
// PushingEnvironment returns an os environment to allow hooks to work on push
1414
func PushingEnvironment(doer *User, repo *Repository) []string {
15-
return FullPushingEnvironment(doer, doer, repo, 0)
15+
return FullPushingEnvironment(doer, doer, repo, repo.Name, 0)
1616
}
1717

1818
// FullPushingEnvironment returns an os environment to allow hooks to work on push
19-
func FullPushingEnvironment(author, committer *User, repo *Repository, prID int64) []string {
19+
func FullPushingEnvironment(author, committer *User, repo *Repository, repoName string, prID int64) []string {
2020
isWiki := "false"
21-
if strings.HasSuffix(repo.Name, ".wiki") {
21+
if strings.HasSuffix(repoName, ".wiki") {
2222
isWiki = "true"
2323
}
2424

@@ -32,7 +32,7 @@ func FullPushingEnvironment(author, committer *User, repo *Repository, prID int6
3232
"GIT_AUTHOR_EMAIL="+authorSig.Email,
3333
"GIT_COMMITTER_NAME="+committerSig.Name,
3434
"GIT_COMMITTER_EMAIL="+committerSig.Email,
35-
EnvRepoName+"="+repo.Name,
35+
EnvRepoName+"="+repoName,
3636
EnvRepoUsername+"="+repo.MustOwnerName(),
3737
EnvRepoIsWiki+"="+isWiki,
3838
EnvPusherName+"="+committer.Name,

Diff for: models/wiki.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,13 @@ func (repo *Repository) updateWikiPage(doer *User, oldWikiName, newWikiName, con
217217
if err := git.Push(basePath, git.PushOptions{
218218
Remote: "origin",
219219
Branch: fmt.Sprintf("%s:%s%s", commitHash.String(), git.BranchPrefix, "master"),
220-
Env: PushingEnvironment(doer, repo),
220+
Env: FullPushingEnvironment(
221+
doer,
222+
doer,
223+
repo,
224+
repo.Name+".wiki",
225+
0,
226+
),
221227
}); err != nil {
222228
log.Error("%v", err)
223229
return fmt.Errorf("Push: %v", err)

Diff for: modules/pull/merge.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,13 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor
240240
headUser = doer
241241
}
242242

243-
env := models.FullPushingEnvironment(headUser, doer, pr.BaseRepo, pr.ID)
243+
env := models.FullPushingEnvironment(
244+
headUser,
245+
doer,
246+
pr.BaseRepo,
247+
pr.BaseRepo.Name,
248+
pr.ID,
249+
)
244250

245251
// Push back to upstream.
246252
if err := git.NewCommand("push", "origin", pr.BaseBranch).RunInDirTimeoutEnvPipeline(env, -1, tmpBasePath, nil, &errbuf); err != nil {

0 commit comments

Comments
 (0)