File tree 3 files changed +21
-2
lines changed
3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ inputs:
13
13
suggestions :
14
14
description : " Add suggestion comments of restyled changes"
15
15
default : false
16
+ suggestion-limit :
17
+ description : " Limit the number of suggestion comments left"
18
+ required : false
16
19
show-patch :
17
20
description : " Log the patch produced by Restyled with git format-patch"
18
21
default : true
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export type Inputs = {
20
20
paths : string [ ] ;
21
21
githubToken : string ;
22
22
suggestions : boolean ;
23
+ suggestionsLimit : number | null ;
23
24
showPatch : boolean ;
24
25
showPatchCommand : boolean ;
25
26
committerEmail : string ;
@@ -44,12 +45,20 @@ export function getInputs(): Inputs {
44
45
}
45
46
}
46
47
48
+ const rawSuggestionLimit = core . getInput ( "suggestion-limit" , {
49
+ required : false ,
50
+ } ) ;
51
+
47
52
return {
48
53
paths,
49
54
githubToken : core . getInput ( "github-token" , { required : true } ) ,
50
55
suggestions : core . getBooleanInput ( "suggestions" , {
51
56
required : true ,
52
57
} ) ,
58
+ suggestionsLimit :
59
+ rawSuggestionLimit && rawSuggestionLimit !== ""
60
+ ? parseInt ( rawSuggestionLimit , 10 )
61
+ : null ,
53
62
showPatch : core . getBooleanInput ( "show-patch" , {
54
63
required : true ,
55
64
} ) ,
Original file line number Diff line number Diff line change @@ -106,13 +106,20 @@ async function run() {
106
106
107
107
let n = 0 ;
108
108
const ps = suggestions . map ( ( s ) => {
109
- if ( s . skipReason ) {
109
+ const limitSkipReason =
110
+ inputs . suggestionsLimit && n >= inputs . suggestionsLimit
111
+ ? "limit reached"
112
+ : null ;
113
+
114
+ const skipReason = s . skipReason ?? limitSkipReason ;
115
+
116
+ if ( skipReason ) {
110
117
const line =
111
118
s . startLine !== s . endLine
112
119
? `${ s . startLine } -${ s . endLine } `
113
120
: `${ s . startLine } ` ;
114
121
const location = `${ s . path } :${ line } ` ;
115
- core . warning ( `[${ location } ]: Skipping suggestion: ${ s . skipReason } ` ) ;
122
+ core . warning ( `[${ location } ]: Skipping suggestion: ${ skipReason } ` ) ;
116
123
return Promise . resolve ( ) ;
117
124
} else {
118
125
n += 1 ;
You can’t perform that action at this time.
0 commit comments