Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix package names pulled from body #217

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions __tests__/entry-extractor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,19 @@ test('extracts mulitple entries from body', async () => {
expect(entries).toHaveLength(3)

let entry = entries[0]
expect(entry.package).toStrictEqual('`package`')
expect(entry.package).toStrictEqual('package')
expect(entry.repository).toStrictEqual('owner/repo')
expect(entry.oldVersion).toStrictEqual('0.30.7')
expect(entry.newVersion).toStrictEqual('0.32.6')

entry = entries[1]
expect(entry.package).toStrictEqual('`another-package`')
expect(entry.package).toStrictEqual('another-package')
expect(entry.repository).toStrictEqual('owner/repo')
expect(entry.oldVersion).toStrictEqual('4.25.7')
expect(entry.newVersion).toStrictEqual('5.12.9')

entry = entries[2]
expect(entry.package).toStrictEqual('`yet-another-package`')
expect(entry.package).toStrictEqual('yet-another-package')
expect(entry.repository).toStrictEqual('owner/repo')
expect(entry.oldVersion).toStrictEqual('2.24.0')
expect(entry.newVersion).toStrictEqual('3.12.3')
Expand Down
286 changes: 128 additions & 158 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/entry-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
}

export function getDependabotEntries(event: WebhookPayload): DependabotEntry[] {
const pullRequestNumber: number = event.pull_request!.number

Check warning on line 24 in src/entry-extractor.ts

View workflow job for this annotation

GitHub Actions / unit-tests

Forbidden non-null assertion

Check warning on line 24 in src/entry-extractor.ts

View workflow job for this annotation

GitHub Actions / unit-tests

Forbidden non-null assertion
const repository: string | undefined = event.repository?.full_name
const titleResult = ENTRY_REGEX.exec(event.pull_request!.title)

Check warning on line 26 in src/entry-extractor.ts

View workflow job for this annotation

GitHub Actions / unit-tests

Forbidden non-null assertion

Check warning on line 26 in src/entry-extractor.ts

View workflow job for this annotation

GitHub Actions / unit-tests

Forbidden non-null assertion
if (titleResult !== null) {
return [
{
Expand All @@ -36,7 +36,7 @@
]
}

const body = event.pull_request!.body ?? ''

Check warning on line 39 in src/entry-extractor.ts

View workflow job for this annotation

GitHub Actions / unit-tests

Forbidden non-null assertion

Check warning on line 39 in src/entry-extractor.ts

View workflow job for this annotation

GitHub Actions / unit-tests

Forbidden non-null assertion
const entries = getEntriesFromBody(pullRequestNumber, repository, body)
if (entries.length === 0) {
throw new Error('No dependabot entries! found')
Expand All @@ -57,7 +57,9 @@
entries.push({
pullRequestNumber,
repository,
package: match[1],

// Remove redundant '`' characters on pacakges pulled from the body
package: match[1].replaceAll('`', ''),
oldVersion: match[2],
newVersion: match[3]
})
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"target": "ES2021", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
Expand Down
Loading