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: check that the author is defined when comparing it with dependab… #258

Merged
merged 2 commits into from Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.js
Expand Up @@ -10463,7 +10463,7 @@ module.exports = async function run() {

const commits = await client.getPullRequestCommits(pr.number)

if (!commits.every(commit => commit.author.login === dependabotAuthor)) {
if (!commits.every(commit => commit.author?.login === dependabotAuthor)) {
return logWarning('PR contains non dependabot commits, skipping.')
}

Expand Down
2 changes: 1 addition & 1 deletion src/action.js
Expand Up @@ -56,7 +56,7 @@ module.exports = async function run() {

const commits = await client.getPullRequestCommits(pr.number)

if (!commits.every(commit => commit.author.login === dependabotAuthor)) {
if (!commits.every(commit => commit.author?.login === dependabotAuthor)) {
return logWarning('PR contains non dependabot commits, skipping.')
}

Expand Down
4 changes: 1 addition & 3 deletions test/action.test.js
Expand Up @@ -150,9 +150,7 @@ tap.test('should skip PR with non dependabot commit', async () => {

stubs.prCommitsStub.resolves([
{
author: {
login: 'not dependabot',
},
author: undefined,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to test both cases, not just once. to avoid duplication of the whole test, just create an array with the two users and create the 2 tests in a loop

},
])

Expand Down