Skip to content

Commit

Permalink
Make parseVCSUri less brittle
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed May 13, 2024
1 parent 4f2addc commit a80a37e
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1194,9 +1194,19 @@ private static List<PolicyRule> toPolicyRulesList(Map<String, PolicyRuleConfig>
}

private static String parseVCSUri(VCSUriConfig config, ScmInfo scm) {
if (config.enabled) {
return config.override.orElseGet(() -> scm != null ? Git.sanitizeRemoteUrl(scm.getRemote().get("origin")) : null);
if (!config.enabled) {
return null;
}
return null;
if (config.override.isPresent()) {
return config.override.get();
}
if (scm == null) {
return null;
}
String originRemote = scm.getRemote().get("origin");
if (originRemote == null || originRemote.isBlank()) {
return null;
}
return Git.sanitizeRemoteUrl(originRemote);
}
}

0 comments on commit a80a37e

Please sign in to comment.