File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -506,20 +506,30 @@ try {
506
506
507
507
await withSpinner (
508
508
async ( ) => {
509
+ const getLabelName = ( label ) => label . name ;
510
+
509
511
const existingLabels = JSON . parse (
510
512
( await $ `gh label list --json name` ) . stdout || "[]"
511
- ) ;
513
+ ) . map ( getLabelName ) ;
512
514
513
515
const outcomeLabels = await readFileAsJSON ( "./script/labels.json" ) ;
514
516
515
517
for ( const outcome of outcomeLabels ) {
516
518
const action = existingLabels . some (
517
- ( existing ) => existing . name === outcome . name
519
+ ( existing ) => existing === outcome . name
518
520
)
519
521
? "edit"
520
522
: "create" ;
521
523
await $ `gh label ${ action } ${ outcome . name } --color ${ outcome . color } --description ${ outcome . description } ` ;
522
524
}
525
+
526
+ const allowedLabels = new Set ( outcomeLabels . map ( getLabelName ) ) ;
527
+
528
+ for ( const existingLabel of existingLabels ) {
529
+ if ( ! allowedLabels . has ( existingLabel ) ) {
530
+ await $ `gh label delete ${ existingLabel } --yes` ;
531
+ }
532
+ }
523
533
} ,
524
534
{
525
535
startText : `Hydrating repository labels...` ,
You can’t perform that action at this time.
0 commit comments