Skip to content

Commit a30bbbb

Browse files
authored
Merge pull request #166 from pangaeatech/allow-other-commits
Allow fetch-metadata to run on a PR even if it has additional commits…
2 parents 749688a + 9a3daaf commit a30bbbb

File tree

3 files changed

+12
-47
lines changed

3 files changed

+12
-47
lines changed

dist/index.js

Lines changed: 2 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dependabot/verified_commits.test.ts

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,6 @@ test('it returns false for an event triggered by someone other than Dependabot',
3333
)
3434
})
3535

36-
test('it returns false if there is more than 1 commit', async () => {
37-
nock('https://api.github.com').get('/repos/dependabot/dependabot/pulls/101/commits')
38-
.reply(200, [
39-
{
40-
commit: {
41-
message: 'Bump lodash from 1.0.0 to 2.0.0'
42-
}
43-
},
44-
{
45-
commit: {
46-
message: 'Add some more things.'
47-
}
48-
}
49-
])
50-
51-
expect(await getMessage(mockGitHubClient, mockGitHubPullContext())).toBe(false)
52-
53-
expect(core.warning).toHaveBeenCalledWith(
54-
expect.stringContaining("It looks like this PR has contains commits that aren't part of a Dependabot update.")
55-
)
56-
})
57-
5836
test('it returns false if the commit was authored by someone other than Dependabot', async () => {
5937
nock('https://api.github.com').get('/repos/dependabot/dependabot/pulls/101/commits')
6038
.reply(200, [
@@ -71,7 +49,7 @@ test('it returns false if the commit was authored by someone other than Dependab
7149
expect(await getMessage(mockGitHubClient, mockGitHubPullContext())).toBe(false)
7250

7351
expect(core.warning).toHaveBeenCalledWith(
74-
expect.stringContaining("It looks like this PR has contains commits that aren't part of a Dependabot update.")
52+
expect.stringContaining('It looks like this PR was not created by Dependabot, refusing to proceed.')
7553
)
7654
})
7755

@@ -124,6 +102,11 @@ test('it returns the commit message for a PR authored exclusively by Dependabot
124102
verified: true
125103
}
126104
}
105+
},
106+
{
107+
commit: {
108+
message: 'Add some more things.'
109+
}
127110
}
128111
])
129112

src/dependabot/verified_commits.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,13 @@ export async function getMessage (client: InstanceType<typeof GitHub>, context:
3232
pull_number: pr.number
3333
})
3434

35-
if (commits.length > 1) {
36-
warnOtherCommits()
37-
return false
38-
}
39-
4035
const { commit, author } = commits[0]
4136

4237
if (author?.login !== DEPENDABOT_LOGIN) {
43-
warnOtherCommits()
38+
// TODO: Promote to setFailed
39+
core.warning(
40+
'It looks like this PR was not created by Dependabot, refusing to proceed.'
41+
)
4442
return false
4543
}
4644

@@ -55,14 +53,6 @@ export async function getMessage (client: InstanceType<typeof GitHub>, context:
5553
return commit.message
5654
}
5755

58-
function warnOtherCommits (): void {
59-
core.warning(
60-
"It looks like this PR has contains commits that aren't part of a Dependabot update. " +
61-
"Try using '@dependabot rebase' to remove merge commits or '@dependabot recreate' to remove " +
62-
'any non-Dependabot changes.'
63-
)
64-
}
65-
6656
export async function getAlert (name: string, version: string, directory: string, client: InstanceType<typeof GitHub>, context: Context): Promise<dependencyAlert> {
6757
const alerts: any = await client.graphql(`
6858
{

0 commit comments

Comments
 (0)