Skip to content

Commit 222e06b

Browse files
committed
fix: address Copilot code review feedback
- Move early return condition to after stale label determination to ensure stale labels are always removed - Add 'maintain' role to privileged approval permission levels - Downgrade pull-requests permission to 'read' to enforce least privilege Signed-off-by: darshit2308 <darshit2308@gmail.com>
1 parent 6e67c49 commit 222e06b

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

.github/scripts/review-sync/labels.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ async function countApprovals(github, owner, repo, prNumber) {
137137

138138
const permission = await getPermissionLevel(github, owner, repo, username);
139139

140-
if (permission === 'admin' || permission === 'write') {
140+
if (permission === 'admin' || permission === 'maintain' || permission === 'write') {
141141
writeApproval++;
142142
} else {
143143
// read, none, or any unexpected value → soft approval
@@ -205,17 +205,17 @@ async function syncLabel(github, owner, repo, pr, dryRun) {
205205
`→ ${correctLabel.name}`
206206
);
207207

208-
// Check if the correct label is already present
209-
if (currentLabels.includes(correctLabel.name)) {
210-
console.log(` ✓ Already has "${correctLabel.name}". No change needed.`);
211-
return false;
212-
}
213-
214208
// Determine which stale queue labels to remove
215209
const staleLabels = currentLabels.filter(
216210
(name) => ALL_QUEUE_LABEL_NAMES.includes(name) && name !== correctLabel.name
217211
);
218212

213+
// Check if the correct label is already present AND there are no stale labels to remove
214+
if (currentLabels.includes(correctLabel.name) && staleLabels.length === 0) {
215+
console.log(` ✓ Already has "${correctLabel.name}". No change needed.`);
216+
return false;
217+
}
218+
219219
if (dryRun) {
220220
console.log(` [DRY RUN] Would add "${correctLabel.name}".`);
221221
if (staleLabels.length > 0) {

.github/workflows/review-sync.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ on:
2323
type: string
2424

2525
permissions:
26-
pull-requests: write
26+
pull-requests: read
2727
issues: write
2828
contents: read
2929

0 commit comments

Comments
 (0)