Skip to content
Snippets Groups Projects
Commit 5b7f74ed authored by Martin Lowe's avatar Martin Lowe :flag_ca:
Browse files

fix(gh): remove doubled umport of GithubHelper in webhook resource class

parent 8a8d7e3f
No related branches found
No related tags found
1 merge request!214update: add GH webhook event check for "installation" type events
Pipeline #68901 passed
......@@ -57,8 +57,6 @@ public class GithubWebhooksResource extends CommonResource {
@Inject
GithubApplicationService ghAppService;
@Inject
GithubHelper validationHelper;
@Inject
CaptchaHelper captchaHelper;
@Inject
......@@ -82,7 +80,7 @@ public class GithubWebhooksResource extends CommonResource {
// If event isn't a pr or merge_group event, drop as we don't process them
if ("merge_group".equalsIgnoreCase(eventType)) {
// if we're in a merge_group, the HEAD SHA should already be validated, so we don't need to check again
validationHelper.sendMergeQueueStatus(request);
ghHelper.sendMergeQueueStatus(request);
} else if ("pull_request".equalsIgnoreCase(eventType)) {
// check that the pull request isn't somehow missing
if (request.getPullRequest() == null) {
......@@ -91,7 +89,7 @@ public class GithubWebhooksResource extends CommonResource {
PullRequest pr = request.getPullRequest();
// track the request before we start processing
GithubWebhookTracking tracking = validationHelper
GithubWebhookTracking tracking = ghHelper
.retrieveAndUpdateTrackingInformation(wrapper, request.getInstallation().getId(),
request.getRepository().getOwner().getLogin(), request.getRepository().getName(), pr);
......@@ -101,13 +99,13 @@ public class GithubWebhooksResource extends CommonResource {
// prepare for validation process by pre-processing into standard format
ValidationRequest vr = generateRequest(request, pr);
// process the request
validationHelper.handleGithubWebhookValidation(request, vr, wrapper);
ghHelper.handleGithubWebhookValidation(request, vr, wrapper);
} catch (Exception e) {
// set the revalidation flag to reprocess if the initial attempt fails before exiting
setRevalidationFlagForTracking(tracking);
}
} else if ("installation".equalsIgnoreCase(eventType)) {
// manually trigger the application installation update
// manually trigger the application installation update
ghHelper.updateAppInstallationRecords();
}
......@@ -147,7 +145,7 @@ public class GithubWebhooksResource extends CommonResource {
}
// get the tracking if it exists, create it if it doesn't, and fail out if there is an issue
GithubWebhookTracking tracking = validationHelper
GithubWebhookTracking tracking = ghHelper
.retrieveAndUpdateTrackingInformation(wrapper, installationId, orgName, repoName, prResponse.get());
if (tracking == null) {
throw new ServerErrorException(String
......@@ -176,7 +174,7 @@ public class GithubWebhooksResource extends CommonResource {
throw new ServerErrorException("Current validation is in a bad state, pull request information missing",
Status.INTERNAL_SERVER_ERROR);
}
boolean isSuccessful = validationHelper
boolean isSuccessful = ghHelper
.handleGithubWebhookValidation(request, generateRequest(request, request.getPullRequest()), wrapper)
.getPassed();
LOGGER.debug("Revalidation for request for '{}#{}' was {}successful.", sanitizedRepoName, prNo, isSuccessful ? "" : " not");
......@@ -200,7 +198,7 @@ public class GithubWebhooksResource extends CommonResource {
* @return the Validation Request body to be used in validating data
*/
private ValidationRequest generateRequest(GithubWebhookRequest request, PullRequest pr) {
return validationHelper
return ghHelper
.generateRequest(request.getInstallation().getId(), request.getRepository().getOwner().getLogin(),
request.getRepository().getName(), pr.getNumber(), request.getRepository().getHtmlUrl());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment