-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle branch names containing hyphen separators
- Loading branch information
1 parent
518993c
commit a44a9df
Showing
5 changed files
with
154 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,7 +106,7 @@ test('it supports multiple dependencies within a single fragment', async () => { | |
return Promise.resolve(0) | ||
} | ||
|
||
const updatedDependencies = await updateMetadata.parse(commitMessage, body, 'dependabot/nuget/api/main/coffee-rails', 'main', getAlert, getScore) | ||
const updatedDependencies = await updateMetadata.parse(commitMessage, body, 'dependabot/nuget/api/main/coffee-rails/and/coffeescript', 'main', getAlert, getScore) | ||
|
||
expect(updatedDependencies).toHaveLength(2) | ||
|
||
|
@@ -299,6 +299,105 @@ test('it properly handles dependencies which contain slashes', async () => { | |
expect(updatedDependencies[0].dependencyGroup).toEqual('') | ||
}) | ||
|
||
test('it handles branch names with hyphen separator', async () => { | ||
const commitMessage = | ||
'- [Release notes](https://github.com/fsevents/fsevents/releases)\n' + | ||
'- [Commits](fsevents/[email protected])\n' + | ||
'\n' + | ||
'---\n' + | ||
'updated-dependencies:\n' + | ||
'- dependency-name: fsevents\n' + | ||
' dependency-type: indirect\n' + | ||
'...\n' + | ||
'\n' + | ||
'Signed-off-by: dependabot[bot] <[email protected]>' | ||
|
||
const getAlert = async () => Promise.resolve({ alertState: '', ghsaId: '', cvss: 0 }) | ||
const getScore = async () => Promise.resolve(0) | ||
const updatedDependencies = await updateMetadata.parse(commitMessage, '', 'dependabot-npm_and_yarn-fsevents-1.2.13', 'master', getAlert, getScore) | ||
|
||
expect(updatedDependencies[0].directory).toEqual('/') | ||
}) | ||
|
||
test('it handles branch names with hyphen separator and manifest files in nested directories', async () => { | ||
const commitMessage = | ||
'- [Release notes](https://github.com/fsevents/fsevents/releases)\n' + | ||
'- [Commits](fsevents/[email protected])\n' + | ||
'\n' + | ||
'---\n' + | ||
'updated-dependencies:\n' + | ||
'- dependency-name: fsevents\n' + | ||
' dependency-type: indirect\n' + | ||
'...\n' + | ||
'\n' + | ||
'Signed-off-by: dependabot[bot] <[email protected]>' | ||
|
||
const getAlert = async () => Promise.resolve({ alertState: '', ghsaId: '', cvss: 0 }) | ||
const getScore = async () => Promise.resolve(0) | ||
const updatedDependencies = await updateMetadata.parse(commitMessage, '', 'dependabot-npm_and_yarn-nested-nested-fsevents-1.2.13', 'master', getAlert, getScore) | ||
|
||
expect(updatedDependencies[0].directory).toEqual('/nested/nested') | ||
}) | ||
|
||
test('it handles branch names with hyphen separator and dependency names with forward slashes', async () => { | ||
const commitMessage = | ||
'- [Release notes](https://github.com/composer/composer/releases)\n' + | ||
'- [Changelog](https://github.com/composer/composer/blob/main/CHANGELOG.md)\n' + | ||
'- [Commits](composer/[email protected])\n' + | ||
'\n' + | ||
'---\n' + | ||
'updated-dependencies:\n' + | ||
'- dependency-name: composer/composer\n' + | ||
' dependency-type: indirect\n' + | ||
'...\n' + | ||
'\n' + | ||
'Signed-off-by: dependabot[bot] <[email protected]>' | ||
|
||
const getAlert = async () => Promise.resolve({ alertState: '', ghsaId: '', cvss: 0 }) | ||
const getScore = async () => Promise.resolve(0) | ||
const updatedDependencies = await updateMetadata.parse(commitMessage, '', 'dependabot-composer-composer-composer-2.6.5', 'master', getAlert, getScore) | ||
|
||
expect(updatedDependencies[0].directory).toEqual('/') | ||
}) | ||
|
||
test('it handles branch names with hyphen separator and multiple dependencies', async () => { | ||
const commitMessage = | ||
'Updates `twilio-video` from 2.7.0 to 2.28.1\n' + | ||
'- [Release notes](https://github.com/twilio/twilio-video.js/releases)\n' + | ||
'- [Changelog](https://github.com/twilio/twilio-video.js/blob/master/CHANGELOG.md)\n' + | ||
'- [Commits](twilio/[email protected])\n' + | ||
'\n' + | ||
'Updates `@types/twilio-video` from 2.7.0 to 2.11.0\n' + | ||
'- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)\n' + | ||
'- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/twilio-video)\n' + | ||
'\n' + | ||
'---\n' + | ||
'updated-dependencies:\n' + | ||
'- dependency-name: twilio-video\n' + | ||
' dependency-type: direct:production\n' + | ||
' update-type: version-update:semver-minor\n' + | ||
'- dependency-name: "@types/twilio-video"\n' + | ||
' dependency-type: direct:development\n' + | ||
' update-type: version-update:semver-minor\n' + | ||
'...\n' + | ||
'\n' + | ||
'Signed-off-by: dependabot[bot] <[email protected]>' | ||
|
||
const getAlert = async () => Promise.resolve({ alertState: '', ghsaId: '', cvss: 0 }) | ||
const getScore = async () => Promise.resolve(0) | ||
|
||
const updatedDependencies = await updateMetadata.parse( | ||
commitMessage, | ||
'', | ||
'dependabot-npm_and_yarn-twilio-video-and-types-twilio-video-2.28.1', | ||
'master', | ||
getAlert, | ||
getScore | ||
) | ||
|
||
expect(updatedDependencies[0].directory).toEqual('/') | ||
}) | ||
|
||
test('calculateUpdateType should handle all paths', () => { | ||
expect(updateMetadata.calculateUpdateType('', '')).toEqual('') | ||
expect(updateMetadata.calculateUpdateType('', '1')).toEqual('') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,4 +93,5 @@ require('yargs')(hideBin(process.argv)) | |
}) | ||
.demandCommand(1) | ||
.help() | ||
.strict() | ||
.argv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters