Skip to content

Commit 524ca3f

Browse files
committed
fix: no longer using the main repo's env
1 parent 37f9468 commit 524ca3f

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

models/helper_environment.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ func PushingEnvironment(doer *User, repo *Repository) []string {
4343
return FullPushingEnvironment(doer, doer, repo, repo.Name, 0)
4444
}
4545

46+
// WikiPushingEnvironment returns an os environment for wiki repo
47+
func WikiPushingEnvironment(doer *User, repo *Repository) []string {
48+
return FullPushingEnvironment(doer, doer, repo, repo.Name+".wiki", 0)
49+
}
50+
4651
// FullPushingEnvironment returns an os environment to allow hooks to work on push
4752
func FullPushingEnvironment(author, committer *User, repo *Repository, repoName string, prID int64) []string {
4853
isWiki := "false"

modules/repofiles/temp_repo.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,15 @@ func (t *TemporaryUploadRepository) CommitTreeWithDate(author, committer *models
270270

271271
// Push the provided commitHash to the repository branch by the provided user
272272
func (t *TemporaryUploadRepository) push(doer *models.User, commitHash string, branch string, isWiki bool) error {
273+
// Because calls hooks we need to pass in the environment
274+
env := models.PushingEnvironment(doer, t.repo)
273275
repoPath := t.repo.RepoPath()
276+
274277
if isWiki {
275278
repoPath = t.repo.WikiPath()
279+
env = models.WikiPushingEnvironment(doer, t.repo)
276280
}
277281

278-
// Because calls hooks we need to pass in the environment
279-
env := models.PushingEnvironment(doer, t.repo)
280282
if err := git.Push(t.basePath, git.PushOptions{
281283
Remote: repoPath,
282284
Branch: strings.TrimSpace(commitHash) + ":refs/heads/" + strings.TrimSpace(branch),

routers/repo/wiki.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,10 @@ func UploadWikiFilePost(ctx *context.Context, form auth.UploadWikiFileForm) {
707707
Message: message,
708708
Files: form.Files,
709709
}); err != nil {
710+
// FIXME: it will get a "The process cannot access the file because it is being used by another process." error when try to remove
711+
// the uploaded cache file. Upload is successed anyway, but still need to fix this one.
710712
log.Error("Error during upload to repo %-v : %v", ctx.Repo.Repository, err)
713+
ctx.RenderWithErr(ctx.Tr("repo.editor.unable_to_upload_files", "_media", err), tplWikiUpload, &form)
711714
return
712715
}
713716

services/wiki/wiki.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,7 @@ func updateWikiPage(doer *models.User, repo *models.Repository, oldWikiName, new
209209
if err := git.Push(basePath, git.PushOptions{
210210
Remote: "origin",
211211
Branch: fmt.Sprintf("%s:%s%s", commitHash.String(), git.BranchPrefix, "master"),
212-
Env: models.FullPushingEnvironment(
213-
doer,
214-
doer,
215-
repo,
216-
repo.Name+".wiki",
217-
0,
218-
),
212+
Env: models.WikiPushingEnvironment(doer, repo),
219213
}); err != nil {
220214
log.Error("%v", err)
221215
if git.IsErrPushOutOfDate(err) || git.IsErrPushRejected(err) {

0 commit comments

Comments
 (0)