Skip to content

Commit 758c3a0

Browse files
committed
Add GITEA_PR_INDEX env variable to githooks
1 parent 372d24b commit 758c3a0

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

modules/repository/env.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const (
2525
EnvKeyID = "GITEA_KEY_ID" // public key ID
2626
EnvDeployKeyID = "GITEA_DEPLOY_KEY_ID"
2727
EnvPRID = "GITEA_PR_ID"
28+
EnvPRIndex = "GITEA_PR_INDEX"
2829
EnvPushTrigger = "GITEA_PUSH_TRIGGER"
2930
EnvIsInternal = "GITEA_INTERNAL_PUSH"
3031
EnvAppURL = "GITEA_ROOT_URL"
@@ -50,11 +51,11 @@ func InternalPushingEnvironment(doer *user_model.User, repo *repo_model.Reposito
5051

5152
// PushingEnvironment returns an os environment to allow hooks to work on push
5253
func PushingEnvironment(doer *user_model.User, repo *repo_model.Repository) []string {
53-
return FullPushingEnvironment(doer, doer, repo, repo.Name, 0)
54+
return FullPushingEnvironment(doer, doer, repo, repo.Name, 0, 0)
5455
}
5556

5657
// FullPushingEnvironment returns an os environment to allow hooks to work on push
57-
func FullPushingEnvironment(author, committer *user_model.User, repo *repo_model.Repository, repoName string, prID int64) []string {
58+
func FullPushingEnvironment(author, committer *user_model.User, repo *repo_model.Repository, repoName string, prID int64, prIndex int64) []string {
5859
isWiki := "false"
5960
if strings.HasSuffix(repoName, ".wiki") {
6061
isWiki = "true"
@@ -75,6 +76,7 @@ func FullPushingEnvironment(author, committer *user_model.User, repo *repo_model
7576
EnvPusherID+"="+strconv.FormatInt(committer.ID, 10),
7677
EnvRepoID+"="+strconv.FormatInt(repo.ID, 10),
7778
EnvPRID+"="+strconv.FormatInt(prID, 10),
79+
EnvPRIndex+"="+strconv.FormatInt(prIndex, 10),
7880
EnvAppURL+"="+setting.AppURL,
7981
"SSH_ORIGINAL_COMMAND=gitea-internal",
8082
)

services/pull/merge.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ func doMergeAndPush(ctx context.Context, pr *issues_model.PullRequest, doer *use
403403
pr.BaseRepo,
404404
pr.BaseRepo.Name,
405405
pr.ID,
406+
pr.Index,
406407
)
407408

408409
mergeCtx.env = append(mergeCtx.env, repo_module.EnvPushTrigger+"="+string(pushTrigger))

services/pull/update_rebase.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func updateHeadByRebaseOnToBase(ctx context.Context, pr *issues_model.PullReques
8080
pr.HeadRepo,
8181
pr.HeadRepo.Name,
8282
pr.ID,
83+
pr.Index,
8384
)).
8485
WithDir(mergeCtx.tmpBasePath).
8586
WithStdout(mergeCtx.outbuf).

services/wiki/wiki.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ func updateWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model
223223
repo,
224224
repo.Name+".wiki",
225225
0,
226+
0,
226227
),
227228
}); err != nil {
228229
log.Error("Push failed: %v", err)
@@ -341,6 +342,7 @@ func DeleteWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model
341342
repo,
342343
repo.Name+".wiki",
343344
0,
345+
0,
344346
),
345347
}); err != nil {
346348
if git.IsErrPushOutOfDate(err) || git.IsErrPushRejected(err) {

0 commit comments

Comments
 (0)