File tree Expand file tree Collapse file tree
github-actions/issue-labeling Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,8 +39,17 @@ export class IssueLabeling {
3939 // Initialize labels and issue data
4040 await this . initialize ( ) ;
4141
42- const ai = this . getGenerativeAI ( ) ;
42+ // Determine if the issue already has an area label, if it does we can exit early.
43+ if (
44+ this . issueData ?. labels . some ( ( label ) =>
45+ ( typeof label === 'string' ? label : label . name ) ?. startsWith ( 'area: ' ) ,
46+ )
47+ ) {
48+ this . coreService . info ( 'Issue already has an area label. Skipping.' ) ;
49+ return ;
50+ }
4351
52+ const ai = this . getGenerativeAI ( ) ;
4453 const prompt = `
4554You are a helper for an open source repository.
4655Your task is to allow the user to categorize the issue with an "area: " label.
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ describe('IssueLabeling', () => {
3333 data : {
3434 title : 'Tough Issue' ,
3535 body : 'Complex Body' ,
36+ labels : [ ] ,
3637 } ,
3738 } ) ,
3839 ) ;
@@ -117,4 +118,19 @@ describe('IssueLabeling', () => {
117118 expect ( issueLabeling ) . toBeDefined ( ) ;
118119 expect ( mockCore . getInput ) . not . toHaveBeenCalled ( ) ; // until run is called
119120 } ) ;
121+
122+ it ( 'should skip labeling when issue already has an area label' , async ( ) => {
123+ mockGit . issues . get . and . resolveTo ( {
124+ data : {
125+ title : 'Tough Issue' ,
126+ body : 'Complex Body' ,
127+ labels : [ { name : 'area: core' } ] ,
128+ } ,
129+ } ) ;
130+
131+ await issueLabeling . run ( ) ;
132+
133+ expect ( mockGit . issues . addLabels ) . not . toHaveBeenCalled ( ) ;
134+ expect ( mockCore . info ) . toHaveBeenCalledWith ( 'Issue already has an area label. Skipping.' ) ;
135+ } ) ;
120136} ) ;
Load Diff Large diffs are not rendered by default.
You can’t perform that action at this time.
0 commit comments