File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,7 +37,9 @@ const BOT_ACTORS = new Set(["github-actions[bot]"]);
3737function detectTypeLabelFromTitle ( title ) {
3838 const match = String ( title || "" ) . match ( / ^ ( [ a - z A - Z ] + ) (?: \( [ ^ ) ] * \) ) ? [ ! ] ? \s * : / ) ;
3939 if ( ! match ) return null ;
40- return PREFIX_TO_LABEL [ match [ 1 ] . toLowerCase ( ) ] || null ;
40+ const prefix = match [ 1 ] . toLowerCase ( ) ;
41+ if ( ! Object . prototype . hasOwnProperty . call ( PREFIX_TO_LABEL , prefix ) ) return null ;
42+ return PREFIX_TO_LABEL [ prefix ] ;
4143}
4244
4345/**
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ describe("detectTypeLabelFromTitle", () => {
2020 it ( "returns null without a conventional prefix" , ( ) => {
2121 assert . equal ( detectTypeLabelFromTitle ( "Warn or restart stale app-server" ) , null ) ;
2222 assert . equal ( detectTypeLabelFromTitle ( "" ) , null ) ;
23+ assert . equal ( detectTypeLabelFromTitle ( "constructor: drop legacy" ) , null ) ;
2324 } ) ;
2425} ) ;
2526
Original file line number Diff line number Diff line change @@ -14,8 +14,9 @@ concurrency:
1414
1515permissions :
1616 contents : read
17- pull-requests : write
18- issues : read
17+ # pulls.get only needs read; label mutations use the issues API.
18+ pull-requests : read
19+ issues : write
1920
2021jobs :
2122 label :
2425 - name : Checkout labeler script (default-branch trusted code)
2526 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2627 with :
28+ ref : ${{ github.event.repository.default_branch }}
2729 persist-credentials : false
2830
2931 - name : Apply type label from PR title
@@ -79,12 +81,17 @@ jobs:
7981 documentation: '0075ca',
8082 chore: 'e4e669',
8183 };
82- await github.rest.issues.createLabel({
83- owner, repo,
84- name: plan.detected,
85- color: colors[plan.detected] || 'ededed',
86- });
87- core.info(`Created missing label "${plan.detected}"`);
84+ try {
85+ await github.rest.issues.createLabel({
86+ owner, repo,
87+ name: plan.detected,
88+ color: colors[plan.detected] || 'ededed',
89+ });
90+ core.info(`Created missing label "${plan.detected}"`);
91+ } catch (createErr) {
92+ if (createErr.status !== 422) throw createErr;
93+ core.info(`Label "${plan.detected}" was created concurrently; continuing.`);
94+ }
8895 } else {
8996 throw err;
9097 }
You can’t perform that action at this time.
0 commit comments