File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -188,6 +188,25 @@ describe('git', () => {
188188
189189 expect ( changedFiles ) . toEqual ( [ ] ) ;
190190 } ) ;
191+
192+ it ( 'should return a changed file when it has quotes surrounding files' , async ( ) => {
193+ const execSpy = jest . spyOn ( childProcess , 'execSync' )
194+ . mockReturnValue ( `diff --git "a/lala.ts" "b/lala.ts"
195+ new file mode 100644
196+ index 000000000..26b848d67
197+ Binary files /dev/null and "b/lala.ts" differ` ) ;
198+
199+ const changedFiles = getChangedFiles ( {
200+ base : branch ,
201+ cwd,
202+ } ) ;
203+
204+ expect ( changedFiles ) . toEqual ( [
205+ { filePath : 'lala.ts' , changedLines : [ ] } ,
206+ ] ) ;
207+
208+ execSpy . mockRestore ( ) ;
209+ } ) ;
191210 } ) ;
192211
193212 describe ( 'getFileFromRevision' , ( ) => {
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ export function getChangedFiles({
102102 . slice ( 1 )
103103 . map ( ( file ) => {
104104 /* istanbul ignore next */
105- const filePath = file . match ( / (?< = a \/ ) .* (? = b \/ ) / g) ?. [ 0 ] ?? '' ;
105+ const filePath = ( file . match ( / (?< = [ " \s ] a \/ ) .* (? = [ " \s ] b \/ ) / g) ?. [ 0 ] ?? '' ) . replace ( '"' , '' ) . trim ( ) ;
106106 /* istanbul ignore next */
107107 const changedLines =
108108 file . match ( / (?< = @ @ - .* \+ ) \d * (? = .* @ @ ) / g) ?. map ( ( line ) => + line ) ?? [ ] ;
You can’t perform that action at this time.
0 commit comments