Skip to content

Commit 76fe3af

Browse files
committed
Vibe code (Claude Sonnet 4) label updating code to just replace status labels and not replace entirely all labels
1 parent 23a1b6c commit 76fe3af

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

.github/workflows/lib/approval.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,44 @@ class ApprovalManager {
5959

6060
// Helper to update issue status and labels
6161
async updateIssueStatus(status) {
62-
const labels = [];
62+
// Get current issue to preserve existing labels
63+
const issue = await this.github.rest.issues.get({
64+
owner: this.org,
65+
repo: this.repo,
66+
issue_number: this.issueNumber,
67+
});
68+
69+
// Filter out existing status labels
70+
const statusLabels = ["accepted", "turned-down", "timed-out", "proposed"];
71+
const existingLabels = issue.data.labels
72+
.map(label => typeof label === 'string' ? label : label.name)
73+
.filter(label => !statusLabels.includes(label));
6374

75+
// Determine new status label
76+
let newStatusLabel;
6477
switch (status) {
6578
case "✅ Approved":
66-
labels.push("accepted");
79+
newStatusLabel = "accepted";
6780
break;
6881
case "❌ Rejected":
69-
labels.push("turned-down");
82+
newStatusLabel = "turned-down";
7083
break;
7184
case "⏰ Timed Out":
72-
labels.push("timed-out");
85+
newStatusLabel = "timed-out";
7386
break;
7487
default:
75-
labels.push("proposed");
88+
newStatusLabel = "proposed";
7689
}
7790

91+
// Combine existing non-status labels with new status label
92+
const updatedLabels = [...existingLabels, newStatusLabel];
93+
7894
// Update labels
7995
await this.github.rest.issues.update({
8096
owner: this.org,
8197
repo: this.repo,
8298
issue_number: this.issueNumber,
83-
labels: labels,
99+
labels: updatedLabels,
84100
});
85101
}
86102

0 commit comments

Comments
 (0)