Skip to content

Commit

Permalink
fix(core): correctly convert swingletree severity to github annotatio…
Browse files Browse the repository at this point in the history
…n severities
  • Loading branch information
error418 committed Oct 1, 2019
1 parent d33eb8f commit 0f672f9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/core/github/commit-status-sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ class CommitStatusSender {
return result;
}

private convertSwingletreeSeverity(severity: Swingletree.Severity): "notice" | "warning" | "failure" {
let result: "notice" | "warning" | "failure" = "notice";

switch (severity) {
case Swingletree.Severity.BLOCKER: result = "failure"; break;
case Swingletree.Severity.MAJOR:
case Swingletree.Severity.WARNING: result = "warning"; break;
case Swingletree.Severity.WARNING: result = "warning"; break;
}

return result;
}

private convertToCheckAnnotations(annotations: Swingletree.Annotation[]): ChecksCreateParamsOutputAnnotations[] {
return annotations.filter(i => i instanceof Swingletree.FileAnnotation)
.map(annotation => {
Expand All @@ -49,7 +62,7 @@ class CommitStatusSender {
end_line: item.end || 1,
title: item.title,
message: item.detail,
annotation_level: item.severity
annotation_level: this.convertSwingletreeSeverity(item.severity)
} as ChecksCreateParamsOutputAnnotations;
});
}
Expand Down Expand Up @@ -112,7 +125,7 @@ class CommitStatusSender {
})
.catch((error: any) => {
LOGGER.error("could not persist check status for %s with commit id %s", githubSource.repo, githubSource.sha);
LOGGER.error(error);
LOGGER.error(JSON.stringify(error, null, 2));
});

return checkCreateParams;
Expand Down

0 comments on commit 0f672f9

Please sign in to comment.