Skip to content

Commit d89861f

Browse files
committed
Use correct variable name.
1 parent 4c3e56d commit d89861f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

cmd/hook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Gitea or set your environment appropriately.`, "")
179179
GitObjectDirectory: os.Getenv(private.GitObjectDirectory),
180180
GitQuarantinePath: os.Getenv(private.GitQuarantinePath),
181181
GitPushOptions: pushOptions(),
182-
ProtectedBranchID: prID,
182+
PullRequestID: prID,
183183
IsDeployKey: isDeployKey,
184184
}
185185

modules/private/hook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type HookOptions struct {
5353
GitAlternativeObjectDirectories string
5454
GitQuarantinePath string
5555
GitPushOptions GitPushOptions
56-
ProtectedBranchID int64
56+
PullRequestID int64
5757
IsDeployKey bool
5858
}
5959

routers/private/hook.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ func HookPreReceive(ctx *gitea_context.PrivateContext) {
270270
// 6. If we're not allowed to push directly
271271
if !canPush {
272272
// Is this is a merge from the UI/API?
273-
if opts.ProtectedBranchID == 0 {
273+
if opts.PullRequestID == 0 {
274274
// 6a. If we're not merging from the UI/API then there are two ways we got here:
275275
//
276276
// We are changing a protected file and we're not allowed to do that
@@ -292,11 +292,11 @@ func HookPreReceive(ctx *gitea_context.PrivateContext) {
292292
// 6b. Merge (from UI or API)
293293

294294
// Get the PR, user and permissions for the user in the repository
295-
pr, err := models.GetPullRequestByID(opts.ProtectedBranchID)
295+
pr, err := models.GetPullRequestByID(opts.PullRequestID)
296296
if err != nil {
297-
log.Error("Unable to get PullRequest %d Error: %v", opts.ProtectedBranchID, err)
297+
log.Error("Unable to get PullRequest %d Error: %v", opts.PullRequestID, err)
298298
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
299-
"err": fmt.Sprintf("Unable to get PullRequest %d Error: %v", opts.ProtectedBranchID, err),
299+
"err": fmt.Sprintf("Unable to get PullRequest %d Error: %v", opts.PullRequestID, err),
300300
})
301301
return
302302
}
@@ -354,13 +354,13 @@ func HookPreReceive(ctx *gitea_context.PrivateContext) {
354354
if models.IsErrNotAllowedToMerge(err) {
355355
log.Warn("Forbidden: User %d is not allowed push to protected branch %s in %-v and pr #%d is not ready to be merged: %s", opts.UserID, branchName, repo, pr.Index, err.Error())
356356
ctx.JSON(http.StatusForbidden, map[string]interface{}{
357-
"err": fmt.Sprintf("Not allowed to push to protected branch %s and pr #%d is not ready to be merged: %s", branchName, opts.ProtectedBranchID, err.Error()),
357+
"err": fmt.Sprintf("Not allowed to push to protected branch %s and pr #%d is not ready to be merged: %s", branchName, opts.PullRequestID, err.Error()),
358358
})
359359
return
360360
}
361361
log.Error("Unable to check if mergable: protected branch %s in %-v and pr #%d. Error: %v", opts.UserID, branchName, repo, pr.Index, err)
362362
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
363-
"err": fmt.Sprintf("Unable to get status of pull request %d. Error: %v", opts.ProtectedBranchID, err),
363+
"err": fmt.Sprintf("Unable to get status of pull request %d. Error: %v", opts.PullRequestID, err),
364364
})
365365
return
366366
}

0 commit comments

Comments
 (0)