Skip to content

Commit ef0ae7e

Browse files
committed
fix: overall status
1 parent ae044fd commit ef0ae7e

2 files changed

Lines changed: 27 additions & 16 deletions

File tree

actions/codeowners-analysis/dist/index.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25620,21 +25620,27 @@ async function formatAllReviewsSummary(summary2) {
2562025620
for (const file of files) {
2562125621
const ownerStatuses = summary2.fileToStatus[file] || [];
2562225622
const owners = summary2.fileToOwners[file] && summary2.fileToOwners[file].length > 0 ? summary2.fileToOwners[file] : ["_No owners found_"];
25623-
const fileOverall = getOverallState(ownerStatuses);
2562425623
if (ownerStatuses.length === 0) {
25624+
const icon = owners.length === 0 ? iconFor("UNKNOWN") : iconFor("PENDING" /* Pending */);
2562525625
rows.push([
2562625626
{ data: file },
25627-
{ data: fileOverall ? iconFor(fileOverall) : "-" },
25627+
// filename
25628+
{ data: icon },
25629+
// overall status
2562825630
{ data: owners[0] ?? "_No owners found_" },
25629-
{ data: "-" },
25631+
// owners
25632+
{ data: icon },
25633+
// review state
2563025634
{ data: "-" }
25635+
// reviewed by
2563125636
]);
2563225637
continue;
2563325638
}
25639+
const fileOverall = getOverallState(ownerStatuses);
2563425640
const rowspan = String(ownerStatuses.length);
2563525641
const filenameCell = { data: file, rowspan };
2563625642
const overallCell = {
25637-
data: fileOverall ? iconFor(fileOverall) : "-",
25643+
data: iconFor(fileOverall),
2563825644
rowspan
2563925645
};
2564025646
ownerStatuses.forEach((status, idx) => {
@@ -25681,7 +25687,7 @@ function iconFor(state) {
2568125687
}
2568225688
}
2568325689
function getOverallState(statuses) {
25684-
if (!statuses || statuses.length === 0) return void 0;
25690+
if (!statuses || statuses.length === 0) return "PENDING" /* Pending */;
2568525691
const precedence = {
2568625692
["CHANGES_REQUESTED" /* ChangesRequested */]: 0,
2568725693
["APPROVED" /* Approved */]: 1,

actions/codeowners-analysis/src/strings.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,28 @@ export async function formatAllReviewsSummary(
6969
? summary.fileToOwners[file]
7070
: ["_No owners found_"];
7171

72-
const fileOverall = getOverallState(ownerStatuses);
73-
7472
if (ownerStatuses.length === 0) {
73+
const icon =
74+
owners.length === 0
75+
? iconFor("UNKNOWN")
76+
: iconFor(PullRequestReviewState.Pending);
77+
7578
rows.push([
76-
{ data: file },
77-
{ data: fileOverall ? iconFor(fileOverall) : "-" },
78-
{ data: owners[0] ?? "_No owners found_" },
79-
{ data: "-" },
80-
{ data: "-" },
79+
{ data: file }, // filename
80+
{ data: icon }, // overall status
81+
{ data: owners[0] ?? "_No owners found_" }, // owners
82+
{ data: icon }, // review state
83+
{ data: "-" }, // reviewed by
8184
]);
8285
continue;
8386
}
8487

88+
const fileOverall = getOverallState(ownerStatuses);
89+
8590
const rowspan = String(ownerStatuses.length);
8691
const filenameCell: TCell = { data: file, rowspan };
8792
const overallCell: TCell = {
88-
data: fileOverall ? iconFor(fileOverall) : "-",
93+
data: iconFor(fileOverall),
8994
rowspan,
9095
};
9196

@@ -127,7 +132,7 @@ export async function formatAllReviewsSummary(
127132
.write();
128133
}
129134

130-
function iconFor(state: PullRequestReviewState): string {
135+
function iconFor(state: PullRequestReviewState | "UNKNOWN"): string {
131136
switch (state) {
132137
case PullRequestReviewState.Approved:
133138
return "✅";
@@ -146,8 +151,8 @@ function iconFor(state: PullRequestReviewState): string {
146151

147152
function getOverallState(
148153
statuses: OwnerReviewStatus[],
149-
): PullRequestReviewState | undefined {
150-
if (!statuses || statuses.length === 0) return undefined;
154+
): PullRequestReviewState {
155+
if (!statuses || statuses.length === 0) return PullRequestReviewState.Pending;
151156
const precedence: Record<PullRequestReviewState, number> = {
152157
[PullRequestReviewState.ChangesRequested]: 0,
153158
[PullRequestReviewState.Approved]: 1,

0 commit comments

Comments
 (0)