Skip to content

Commit a82b059

Browse files
committed
differenciate between the code owners
1 parent 69b1e76 commit a82b059

File tree

6 files changed

+26
-35
lines changed

6 files changed

+26
-35
lines changed

src/ResponsesTypes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export type PullRequest = {
3939
head: { ref: string };
4040
};
4141

42-
export const CONTRIBUTOR = 'CONTRIBUTOR';
42+
export const CONTRIBUTORS = ['JasonMillward', 'ppshobi', 'ildyria', 'RonnieTaz', 'sancsin', 'd7415'];
4343
export const APPROVED = 'APPROVED';
4444
export const CHANGES_REQUESTED = 'CHANGES_REQUESTED';
4545
export type PullRequestReview = {
@@ -59,6 +59,7 @@ export type ReviewStatus = {
5959
review?: {
6060
approved: boolean;
6161
changes_requested: boolean;
62+
code_owner_approved: boolean;
6263
by: User[];
6364
};
6465
};

src/components/PrList.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
:key="pr.id"
66
:class="{
77
'flex justify-between gap-16': true,
8-
'transition-opacity duration-100 ease-in-out opacity-50 hover:opacity-100':
9-
pr.draft,
8+
'transition-opacity duration-100 ease-in-out opacity-50 hover:opacity-100': pr.draft,
109
}"
1110
>
1211
<div class="flex flex-col">
@@ -46,18 +45,19 @@
4645
</span>
4746
</div>
4847
</div>
49-
<div v-if="pr.review && pr.review.changes_requested" class="text-red-400 font-bold">
50-
Changes requested.
51-
</div>
48+
<div v-if="pr.review && pr.review.changes_requested" class="text-red-400 font-bold">Changes requested.</div>
5249
<div v-else-if="pr.review && pr.review.approved" class="flex flex-col">
53-
<div class="text-green-500 text-right">Approved</div>
50+
<div
51+
:class="{
52+
'text-right': true,
53+
'text-green-500': pr.review.approved && pr.review.code_owner_approved,
54+
}"
55+
>
56+
Approved
57+
</div>
5458
<div class="text-xs">
5559
by
56-
<UserTag
57-
v-for="(user, idx) in pr.review.by"
58-
:user="user"
59-
:key="`u${pr.id}-${idx}`"
60-
/>
60+
<UserTag v-for="(user, idx) in pr.review.by" :user="user" :key="`u${pr.id}-${idx}`" />
6161
</div>
6262
</div>
6363
<div

src/components/UserTag.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<a :href="props.user.html_url" class="text-muted-color-emphasis">
2+
<a :href="props.user.html_url" class="text-muted-color-emphasis ml-2">
33
<img :src="props.user.avatar_url" class="rounded-full h-4 inline" /> {{ props.user.login }}
44
</a>
55
</template>

src/composables/getData.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
APPROVED,
33
CHANGES_REQUESTED,
4-
CONTRIBUTOR,
4+
CONTRIBUTORS,
55
type PullRequest,
66
type PullRequestReview,
77
type ReviewStatus,
@@ -54,10 +54,7 @@ export function useGetData(
5454
// Ignore all the reviews that are not from the contributors.
5555
const statuses = reviews.reduce(
5656
(acc, review) => {
57-
if (
58-
(review.state === APPROVED || review.state === CHANGES_REQUESTED) &&
59-
review.author_association === CONTRIBUTOR
60-
) {
57+
if (review.state === APPROVED || review.state === CHANGES_REQUESTED) {
6158
acc[review.user.login] = { status: review.state, user: review.user };
6259
}
6360
return acc;
@@ -69,14 +66,18 @@ export function useGetData(
6966
review: {
7067
approved: false,
7168
changes_requested: false,
69+
code_owner_approved: false,
7270
by: [],
7371
},
7472
};
7573
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7674
Object.entries(statuses).forEach(([_, review]) => {
77-
if (review.status === APPROVED) {
75+
if (review.status === APPROVED && CONTRIBUTORS.includes(review.user.login)) {
7876
result.review!.approved = true;
79-
} else if (status === CHANGES_REQUESTED) {
77+
result.review!.code_owner_approved = true;
78+
} else if (review.status === APPROVED) {
79+
result.review!.approved = true;
80+
} else if (review.status === CHANGES_REQUESTED) {
8081
result.review!.changes_requested = true;
8182
}
8283
result.review!.by.push(review.user);

src/composables/octokitWrapper.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import type { QueryStore } from '@/stores/queryStore';
33
import { type Octokit } from 'octokit';
44

55
export function useOctokitWrapper(octokit: Octokit, store: QueryStore) {
6-
async function fetchPullRequests(
7-
owner: string,
8-
repo: string,
9-
): Promise<PullRequest[] | undefined> {
6+
async function fetchPullRequests(owner: string, repo: string): Promise<PullRequest[] | undefined> {
107
const group = {
118
owner: owner,
129
repo: repo,

src/composables/splitter.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ export function useSplitter() {
3636
return ret;
3737
}
3838

39-
function verifyOrder(
40-
is_debug: boolean,
41-
data: { id: string }[],
42-
splitData: SplitData<{ id: string }>[],
43-
) {
39+
function verifyOrder(is_debug: boolean, data: { id: string }[], splitData: SplitData<{ id: string }>[]) {
4440
if (!is_debug) {
4541
return;
4642
}
@@ -60,18 +56,14 @@ export function useSplitter() {
6056
}
6157
const candidate = chunk.iter + idx;
6258
if (expected !== candidate) {
63-
console.error(
64-
`Data mismatch for id ${d.id} (expected ${expected}, got ${candidate})`,
65-
);
59+
console.error(`Data mismatch for id ${d.id} (expected ${expected}, got ${candidate})`);
6660
check = true;
6761
}
6862
});
6963
});
7064

7165
if (check) {
72-
alert(
73-
'Data mismatch found in splitter, please check the console logs and contact the developer.',
74-
);
66+
alert('Data mismatch found in splitter, please check the console logs and contact the developer.');
7567
}
7668
}
7769

0 commit comments

Comments
 (0)