Skip to content

Commit 570675b

Browse files
committed
improve FullPushingEnvironment function
1 parent 7620492 commit 570675b

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

models/helper_environment.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ 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.MustOwnerName(), repo.Name, repo.ID, 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, ownerName, repoName string, repoID, prID int64) []string {
19+
func FullPushingEnvironment(author, committer *User, repo *Repository, repoName string, prID int64) []string {
2020
isWiki := "false"
2121
if strings.HasSuffix(repoName, ".wiki") {
2222
isWiki = "true"
@@ -33,11 +33,11 @@ func FullPushingEnvironment(author, committer *User, ownerName, repoName string,
3333
"GIT_COMMITTER_NAME="+committerSig.Name,
3434
"GIT_COMMITTER_EMAIL="+committerSig.Email,
3535
EnvRepoName+"="+repoName,
36-
EnvRepoUsername+"="+ownerName,
36+
EnvRepoUsername+"="+repo.MustOwnerName(),
3737
EnvRepoIsWiki+"="+isWiki,
3838
EnvPusherName+"="+committer.Name,
3939
EnvPusherID+"="+fmt.Sprintf("%d", committer.ID),
40-
ProtectedBranchRepoID+"="+fmt.Sprintf("%d", repoID),
40+
ProtectedBranchRepoID+"="+fmt.Sprintf("%d", repo.ID),
4141
ProtectedBranchPRID+"="+fmt.Sprintf("%d", prID),
4242
"SSH_ORIGINAL_COMMAND=gitea-internal",
4343
)

models/wiki.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,8 @@ func (repo *Repository) updateWikiPage(doer *User, oldWikiName, newWikiName, con
220220
Env: FullPushingEnvironment(
221221
doer,
222222
doer,
223-
repo.MustOwnerName(),
223+
repo,
224224
repo.Name+".wiki",
225-
repo.ID,
226225
0,
227226
),
228227
}); err != nil {

modules/pull/merge.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,8 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor
243243
env := models.FullPushingEnvironment(
244244
headUser,
245245
doer,
246-
pr.BaseRepo.MustOwnerName(),
246+
pr.BaseRepo,
247247
pr.BaseRepo.Name,
248-
pr.BaseRepo.ID,
249248
pr.ID,
250249
)
251250

0 commit comments

Comments
 (0)