@@ -299,6 +299,67 @@ test('it properly handles dependencies which contain slashes', async () => {
299299 expect ( updatedDependencies [ 0 ] . dependencyGroup ) . toEqual ( '' )
300300} )
301301
302+ test ( 'it handles branch names with hyphen separator' , async ( ) => {
303+ const commitMessage =
304+ '- [Release notes](https://github.com/fsevents/fsevents/releases)\n' +
305+ '- [Commits](fsevents/[email protected] )\n' + 306+ '\n' +
307+ '---\n' +
308+ 'updated-dependencies:\n' +
309+ '- dependency-name: fsevents\n' +
310+ ' dependency-type: indirect\n' +
311+ '...\n' +
312+ '\n' +
313+ 'Signed-off-by: dependabot[bot] <[email protected] >' 314+
315+ const getAlert = async ( ) => Promise . resolve ( { alertState : '' , ghsaId : '' , cvss : 0 } )
316+ const getScore = async ( ) => Promise . resolve ( 0 )
317+ const updatedDependencies = await updateMetadata . parse ( commitMessage , '' , 'dependabot-npm_and_yarn-fsevents-1.2.13' , 'master' , getAlert , getScore )
318+
319+ expect ( updatedDependencies [ 0 ] . directory ) . toEqual ( '/' )
320+ } )
321+
322+ test ( 'it handles branch names with hyphen separator and manifest files in nested directories' , async ( ) => {
323+ const commitMessage =
324+ '- [Release notes](https://github.com/fsevents/fsevents/releases)\n' +
325+ '- [Commits](fsevents/[email protected] )\n' + 326+ '\n' +
327+ '---\n' +
328+ 'updated-dependencies:\n' +
329+ '- dependency-name: fsevents\n' +
330+ ' dependency-type: indirect\n' +
331+ '...\n' +
332+ '\n' +
333+ 'Signed-off-by: dependabot[bot] <[email protected] >' 334+
335+ const getAlert = async ( ) => Promise . resolve ( { alertState : '' , ghsaId : '' , cvss : 0 } )
336+ const getScore = async ( ) => Promise . resolve ( 0 )
337+ const updatedDependencies = await updateMetadata . parse ( commitMessage , '' , 'dependabot-npm_and_yarn-nested-nested-fsevents-1.2.13' , 'master' , getAlert , getScore )
338+
339+ expect ( updatedDependencies [ 0 ] . directory ) . toEqual ( '/nested/nested' )
340+ } )
341+
342+ test ( 'it handles branch names with hyphen separator and dependency names with forward slashes' , async ( ) => {
343+ const commitMessage =
344+ '- [Release notes](https://github.com/composer/composer/releases)\n' +
345+ '- [Changelog](https://github.com/composer/composer/blob/main/CHANGELOG.md)\n' +
346+ '- [Commits](composer/[email protected] )\n' + 347+ '\n' +
348+ '---\n' +
349+ 'updated-dependencies:\n' +
350+ '- dependency-name: composer/composer\n' +
351+ ' dependency-type: indirect\n' +
352+ '...\n' +
353+ '\n' +
354+ 'Signed-off-by: dependabot[bot] <[email protected] >' 355+
356+ const getAlert = async ( ) => Promise . resolve ( { alertState : '' , ghsaId : '' , cvss : 0 } )
357+ const getScore = async ( ) => Promise . resolve ( 0 )
358+ const updatedDependencies = await updateMetadata . parse ( commitMessage , '' , 'dependabot-composer-composer-composer-2.6.5' , 'master' , getAlert , getScore )
359+
360+ expect ( updatedDependencies [ 0 ] . directory ) . toEqual ( '/' )
361+ } )
362+
302363test ( 'calculateUpdateType should handle all paths' , ( ) => {
303364 expect ( updateMetadata . calculateUpdateType ( '' , '' ) ) . toEqual ( '' )
304365 expect ( updateMetadata . calculateUpdateType ( '' , '1' ) ) . toEqual ( '' )
0 commit comments