From 75a9ee6bb4142b0d458cce2e684c81f2d6afea35 Mon Sep 17 00:00:00 2001 From: Easton Crupper <65553218+ecrupper@users.noreply.github.com> Date: Thu, 18 Jul 2024 11:21:24 -0400 Subject: [PATCH] fix(webhook): use correct repo variable to populate client credentials (#1162) * fix(webhook): use correct repo variable to populate client credentials * couple more --- api/webhook/post.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/webhook/post.go b/api/webhook/post.go index e4ac32c3d..89b7907ac 100644 --- a/api/webhook/post.go +++ b/api/webhook/post.go @@ -484,7 +484,7 @@ func PostWebhook(c *gin.Context) { // if the webhook was from a Pull event from a forked repository, verify it is allowed to run if webhook.PullRequest.IsFromFork { - l.Tracef("inside %s workflow for fork PR build %s/%d", repo.GetApproveBuild(), r.GetFullName(), b.GetNumber()) + l.Tracef("inside %s workflow for fork PR build %s/%d", repo.GetApproveBuild(), repo.GetFullName(), b.GetNumber()) switch repo.GetApproveBuild() { case constants.ApproveForkAlways: @@ -496,7 +496,7 @@ func PostWebhook(c *gin.Context) { return case constants.ApproveForkNoWrite: // determine if build sender has write access to parent repo. If not, this call will result in an error - _, err = scm.FromContext(c).RepoAccess(ctx, b.GetSender(), r.GetOwner().GetToken(), r.GetOrg(), r.GetName()) + _, err = scm.FromContext(c).RepoAccess(ctx, b.GetSender(), repo.GetOwner().GetToken(), repo.GetOrg(), repo.GetName()) if err != nil { err = gatekeepBuild(c, b, repo) if err != nil { @@ -512,7 +512,7 @@ func PostWebhook(c *gin.Context) { // // NOTE: this call is cumbersome for repos with lots of contributors. Potential TODO: improve this if // GitHub adds a single-contributor API endpoint. - contributor, err := scm.FromContext(c).RepoContributor(ctx, r.GetOwner(), b.GetSender(), r.GetOrg(), r.GetName()) + contributor, err := scm.FromContext(c).RepoContributor(ctx, repo.GetOwner(), b.GetSender(), repo.GetOrg(), repo.GetName()) if err != nil { util.HandleError(c, http.StatusInternalServerError, err) }