File tree 2 files changed +31
-3
lines changed 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -410,7 +410,7 @@ function validateTitlePrefix(pr: GitHubPr): TestResult {
410
410
}
411
411
412
412
/**
413
- * Check that the PR title uses the typical convention for package names.
413
+ * Check that the PR title uses the typical convention for package names, and is lowercase .
414
414
*
415
415
* For example, "fix(s3)" is preferred over "fix(aws-s3)".
416
416
*/
@@ -427,7 +427,17 @@ function validateTitleScope(pr: GitHubPr): TestResult {
427
427
if ( m && ! scopesExemptFromThisRule . includes ( m [ 2 ] ) ) {
428
428
result . assessFailure (
429
429
! ! ( m [ 2 ] && m [ 3 ] ) ,
430
- `The title of the pull request should omit 'aws-' from the name of modified packages. Use '${ m [ 3 ] } ' instead of '${ m [ 2 ] } '.` ,
430
+ `The title scope of the pull request should omit 'aws-' from the name of modified packages. Use '${ m [ 3 ] } ' instead of '${ m [ 2 ] } '.` ,
431
+ ) ;
432
+ }
433
+
434
+ // Title scope is lowercase
435
+ const scopeRe = / ^ \w + \( ( [ \w _ - ] + ) \) ? : / ; // Isolate the scope
436
+ const scope = scopeRe . exec ( pr . title ) ;
437
+ if ( scope && scope [ 1 ] ) {
438
+ result . assessFailure (
439
+ scope [ 1 ] !== scope [ 1 ] . toLocaleLowerCase ( ) ,
440
+ `The title scope of the pull request should be entirely in lowercase. Use '${ scope [ 1 ] . toLocaleLowerCase ( ) } ' instead.` ,
431
441
) ;
432
442
}
433
443
return result ;
Original file line number Diff line number Diff line change @@ -142,7 +142,25 @@ describe('commit message format', () => {
142
142
} ,
143
143
} ;
144
144
const prLinter = configureMock ( issue , undefined ) ;
145
- await expect ( legacyValidatePullRequestTarget ( prLinter ) ) . rejects . toThrow ( / T h e t i t l e o f t h e p u l l r e q u e s t s h o u l d o m i t ' a w s - ' f r o m t h e n a m e o f m o d i f i e d p a c k a g e s . U s e ' s 3 ' i n s t e a d o f ' a w s - s 3 ' ./ ) ;
145
+ await expect ( legacyValidatePullRequestTarget ( prLinter ) ) . rejects . toThrow ( / T h e t i t l e s c o p e o f t h e p u l l r e q u e s t s h o u l d o m i t ' a w s - ' f r o m t h e n a m e o f m o d i f i e d p a c k a g e s . U s e ' s 3 ' i n s t e a d o f ' a w s - s 3 ' ./ ) ;
146
+ } ) ;
147
+
148
+ test ( 'invalid scope with capital letters' , async ( ) => {
149
+ const issue = {
150
+ number : 1 ,
151
+ title : 'fix(S3): some title' ,
152
+ body : '' ,
153
+ labels : [ { name : 'pr-linter/exempt-test' } , { name : 'pr-linter/exempt-integ-test' } ] ,
154
+ user : {
155
+ login : 'author' ,
156
+ } ,
157
+ } ;
158
+ const prLinter = configureMock ( issue , undefined ) ;
159
+ await expect ( prLinter . validatePullRequestTarget ( ) ) . resolves . toEqual ( expect . objectContaining ( {
160
+ requestChanges : expect . objectContaining ( {
161
+ failures : [ "The title scope of the pull request should be entirely in lowercase. Use 's3' instead." ] ,
162
+ } ) ,
163
+ } ) ) ;
146
164
} ) ;
147
165
148
166
test ( 'valid scope with aws- in summary and body' , async ( ) => {
You can’t perform that action at this time.
0 commit comments