Skip to content

Commit

Permalink
I love nulls
Browse files Browse the repository at this point in the history
  • Loading branch information
carmocca committed Nov 22, 2022
1 parent cf6fc27 commit 0fe368e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 26 deletions.
36 changes: 24 additions & 12 deletions dist/check-group/core/satisfy_expected_checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ var getChecksResult = function (checks, postedChecks) {
var result = "all_passing";
for (var _i = 0, checks_1 = checks; _i < checks_1.length; _i++) {
var check = checks_1[_i];
var relevant = check in postedChecks;
if (relevant && postedChecks[check].conclusion !== "success") {
// at least one check failed
return "has_failure";
if (check in postedChecks) {
var conclusion = postedChecks[check].conclusion;
if (conclusion === null) {
// the check is in progress
result = "pending";
}
else if (conclusion !== "success") {
// the check already failed
return "has_failure";
}
}
if (!relevant || postedChecks[check].conclusion === null) {
// some checks are pending or missing
else {
// the check is missing, hopefully queued
result = "pending";
}
}
Expand All @@ -25,13 +31,19 @@ var getSubProjResult = function (subProjs, postedChecks) {
var subProj = subProjs_1[_i];
for (var _a = 0, _b = subProj.checks; _a < _b.length; _a++) {
var check = _b[_a];
var relevant = check in postedChecks;
if (relevant && postedChecks[check].conclusion !== "success") {
// at least one check failed
return "has_failure";
if (check in postedChecks) {
var conclusion = postedChecks[check].conclusion;
if (conclusion === null) {
// the check is in progress
result = "pending";
}
else if (conclusion !== "success") {
// the check already failed
return "has_failure";
}
}
if (!relevant || postedChecks[check].conclusion === null) {
// some checks are pending or missing
else {
// the check is missing, hopefully queued
result = "pending";
}
}
Expand Down
36 changes: 22 additions & 14 deletions src/check-group/core/satisfy_expected_checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ export const getChecksResult = (
): CheckResult => {
let result: CheckResult = "all_passing";
for (const check of checks) {
const relevant = check in postedChecks
if (relevant && postedChecks[check].conclusion !== "success") {
// at least one check failed
return "has_failure";
}
if (!relevant || postedChecks[check].conclusion === null) {
// some checks are pending or missing
if (check in postedChecks) {
const conclusion = postedChecks[check].conclusion;
if (conclusion === null) {
// the check is in progress
result = "pending";
} else if (conclusion !== "success") {
// the check already failed
return "has_failure";
}
} else {
// the check is missing, hopefully queued
result = "pending";
}
};
Expand All @@ -26,13 +30,17 @@ export const getSubProjResult = (
let result: CheckResult = "all_passing";
for (const subProj of subProjs) {
for (const check of subProj.checks) {
const relevant = check in postedChecks
if (relevant && postedChecks[check].conclusion !== "success") {
// at least one check failed
return "has_failure";
}
if (!relevant || postedChecks[check].conclusion === null) {
// some checks are pending or missing
if (check in postedChecks) {
const conclusion = postedChecks[check].conclusion;
if (conclusion === null) {
// the check is in progress
result = "pending";
} else if (conclusion !== "success") {
// the check already failed
return "has_failure";
}
} else {
// the check is missing, hopefully queued
result = "pending";
}
};
Expand Down

0 comments on commit 0fe368e

Please sign in to comment.