Skip to content
Snippets Groups Projects

Iss #151 - Add forced revalidation for GH validation

Merged Martin Lowe requested to merge (removed):malowe/main/151 into main
3 files
+ 12
5
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -103,10 +103,12 @@ public class GithubValidationHelper {
* @param org the name of the GH organization
* @param repoName the slug of the repo that has the PR to be validated
* @param prNo the PR number for the current request.
* @param forceRevalidation true if revalidation should be forced when there is no changes, false otherwise.
* @return the validated response if it is a valid request, or throws a web exception if there is a problem validating
* the request.
*/
public ValidationResponse validateIncomingRequest(RequestWrapper wrapper, String org, String repoName, Integer prNo) {
public ValidationResponse validateIncomingRequest(RequestWrapper wrapper, String org, String repoName, Integer prNo,
boolean forceRevalidation) {
// use logging helper to sanitize newlines as they aren't needed here
String fullRepoName = LoggingHelper.format(org + '/' + repoName);
// get the installation ID for the given repo if it exists, and if the PR noted exists
@@ -145,7 +147,10 @@ public class GithubValidationHelper {
}
// we only want to update/revalidate for open PRs, so don't do this check if the PR is merged/closed
if ("open".equalsIgnoreCase(prResponse.get().getState()) && commitShas.size() != statuses.size()) {
if (forceRevalidation) {
LOGGER.debug("Forced revalidation for {}#{} has been started", fullRepoName, prNo);
return handleGithubWebhookValidation(GithubWebhookRequest.buildFromTracking(updatedTracking), vr, wrapper);
} else if ("open".equalsIgnoreCase(prResponse.get().getState()) && commitShas.size() != statuses.size()) {
LOGGER.debug("Validation for {}#{} does not seem to be current, revalidating commits", fullRepoName, prNo);
// using the updated tracking, perform the validation
return handleGithubWebhookValidation(GithubWebhookRequest.buildFromTracking(updatedTracking), vr, wrapper);
Loading