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: handle error when branch already exists #48

Merged
merged 12 commits into from
Jan 26, 2019
68 changes: 41 additions & 27 deletions src/Repository/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
const { ResourceNotFoundError } = require('../utils/errors')
const {
ResourceNotFoundError,
AllContributorBotError,
} = require('../utils/errors')

class Repository {
constructor({ repo, owner, github }) {
constructor({ repo, owner, github, defaultBranch }) {
this.github = github
this.repo = repo
this.owner = owner
this.defaultBranch = defaultBranch
this.basedBranch
}

getFullname() {
return `${this.owner}/${this.repo}`
}

setBasedBranch(branchName) {
this.basedBranch = branchName
}

async getFile(filePath) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder how we can take the latest master file and overwrite the current branch :think: like a rebase

Copy link
Contributor

Choose a reason for hiding this comment

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

We probably shouldn't address this here. This is probably a whole ticket in itself. #62.
I'm interested in hearing how you would solve this problem tho.

// https://octokit.github.io/rest.js/#api-Repos-getContents
let file
Expand All @@ -19,6 +28,7 @@ class Repository {
owner: this.owner,
repo: this.repo,
path: filePath,
ref: this.basedBranch,
})
} catch (error) {
if (error.code === 404) {
Expand Down Expand Up @@ -61,17 +71,17 @@ class Repository {
return multipleFilesByPath
}

async getHeadRef(defaultBranch) {
async getHeadRef(branchName) {
sinchang marked this conversation as resolved.
Show resolved Hide resolved
const result = await this.github.git.getRef({
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of checking 404 above when called.

Can we throw an error here? (BranchAlreadyExists) and catch that

owner: this.owner,
repo: this.repo,
ref: `heads/${defaultBranch}`,
ref: `heads/${branchName}`,
})
return result.data.object.sha
}

async createBranch({ branchName, defaultBranch }) {
const fromSha = await this.getHeadRef(defaultBranch)
async createBranch(branchName) {
const fromSha = await this.getHeadRef(this.defaultBranch)

// https://octokit.github.io/rest.js/#api-Git-createRef
await this.github.git.createRef({
Expand Down Expand Up @@ -140,40 +150,44 @@ class Repository {
await Promise.all(createOrUpdateFilesMultiple)
}

async createPullRequest({ title, body, branchName, defaultBranch }) {
const result = await this.github.pulls.create({
owner: this.owner,
repo: this.repo,
title,
body,
head: branchName,
base: defaultBranch,
maintainer_can_modify: true,
})
return result.data.html_url
async createPullRequest({ title, body, branchName }) {
try {
const result = await this.github.pulls.create({
owner: this.owner,
repo: this.repo,
title,
body,
head: branchName,
base: this.defaultBranch,
maintainer_can_modify: true,
})
return { pullRequestURL: result.data.html_url, result: true }
} catch (error) {
// pull request is already open
if (error.code === 422) return { pullRequestURL: '', result: false }
throw error
}
}

async createPullRequestFromFiles({
title,
body,
filesByPath,
branchName,
defaultBranch,
}) {
await this.createBranch({ branchName, defaultBranch })
async createPullRequestFromFiles({ title, body, filesByPath, branchName }) {
if (this.basedBranch === this.defaultBranch)
sinchang marked this conversation as resolved.
Show resolved Hide resolved
this.createBranch(branchName)

await this.createOrUpdateFiles({
filesByPath,
branchName,
})

const pullRequestURL = await this.createPullRequest({
const { pullRequestURL, result } = await this.createPullRequest({
title,
body,
branchName,
defaultBranch,
})

// TODO
if (!result)
throw new AllContributorBotError('Pull request is already open')

return pullRequestURL
}
}
Expand Down
27 changes: 18 additions & 9 deletions src/processIssueComment.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ async function processAddContributor({
optionsConfig,
who,
contributions,
defaultBranch,
}) {
const { name, avatar_url, profile } = await getUserDetails({
github: context.github,
Expand Down Expand Up @@ -56,7 +55,6 @@ async function processAddContributor({
)}.\n\nThis was requested by ${commentReply.replyingToWho()} [in this comment](${commentReply.replyingToWhere()})`,
filesByPath: filesByPathToUpdate,
branchName: `all-contributors/add-${who}`,
defaultBranch,
})

commentReply.reply(
Expand All @@ -65,14 +63,29 @@ async function processAddContributor({
}

async function processIssueComment({ context, commentReply }) {
const commentBody = context.payload.comment.body
const { who, action, contributions } = parseComment(commentBody)
const branchName = `all-contributors/add-${who}`
const defaultBranch = context.payload.repository.default_branch
const repository = new Repository({
...context.repo(),
github: context.github,
defaultBranch,
})

try {
Copy link
Contributor

Choose a reason for hiding this comment

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

This block should happen after fetching config IMO

Copy link
Contributor

Choose a reason for hiding this comment

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

This block should happen inside the processAddContributor block. (For future support of other actions)

await repository.getHeadRef(branchName)
repository.setBasedBranch(branchName)
} catch (error) {
if (error.code !== 404) throw error
repository.setBasedBranch(defaultBranch)
}

const optionsConfig = new OptionsConfig({
repository,
commentReply,
})

try {
await optionsConfig.fetch()
} catch (error) {
Expand All @@ -83,18 +96,14 @@ async function processIssueComment({ context, commentReply }) {
}
}

const commentBody = context.payload.comment.body
const parsedComment = parseComment(commentBody)

if (parsedComment.action === 'add') {
if (action === 'add') {
await processAddContributor({
context,
commentReply,
repository,
optionsConfig,
who: parsedComment.who,
contributions: parsedComment.contributions,
defaultBranch: context.payload.repository.default_branch,
who,
contributions,
})
return
}
Expand Down
18 changes: 9 additions & 9 deletions test/Repository/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ Object {
`;

exports[`Repository createPullRequest with files 1`] = `
Object {
"ref": "refs/heads/all-contributors/add-jakebolam",
"sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
}
`;

exports[`Repository createPullRequest with files 2`] = `
Object {
"branch": "all-contributors/add-jakebolam",
"content": "eyJ0ZXN0IjoidGVzdCBjb250ZW50In0=",
Expand All @@ -24,7 +17,7 @@ Object {
}
`;

exports[`Repository createPullRequest with files 3`] = `
exports[`Repository createPullRequest with files 2`] = `
Object {
"branch": "all-contributors/add-jakebolam",
"content": "VXBkYXRlZCBsaXN0",
Expand All @@ -33,7 +26,7 @@ Object {
}
`;

exports[`Repository createPullRequest with files 4`] = `
exports[`Repository createPullRequest with files 3`] = `
Object {
"branch": "all-contributors/add-jakebolam",
"content": "VXBkYXRlZCBsaXN0IGluIG5lc3RlZCBmb2xkZXI=",
Expand All @@ -42,6 +35,13 @@ Object {
}
`;

exports[`Repository createPullRequest with files 4`] = `
Object {
"ref": "refs/heads/all-contributors/add-jakebolam",
"sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
}
`;

exports[`Repository createPullRequest with files 5`] = `
Object {
"base": "master",
Expand Down
6 changes: 4 additions & 2 deletions test/Repository/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('Repository', () => {
repo: 'all-contributors-bot',
owner: 'all-contributors',
github: mockGithub,
defaultBranch: 'master',
})

const verifyBody = body => {
Expand All @@ -36,9 +37,11 @@ describe('Repository', () => {
})

test('createPullRequest with files', async () => {
const basedBranch = 'master'
repository.setBasedBranch(basedBranch)
nock('https://api.github.com')
.get(
`/repos/all-contributors/all-contributors-bot/git/refs/heads/master`,
`/repos/all-contributors/all-contributors-bot/git/refs/heads/${basedBranch}`,
)
.reply(200, gitGetRefdata)

Expand Down Expand Up @@ -95,7 +98,6 @@ describe('Repository', () => {
},
},
branchName: 'all-contributors/add-jakebolam',
defaultBranch: 'master',
})
expect(pullRequestNumber).toEqual(
'https://github.com/all-contributors/all-contributors-bot/pull/1347',
Expand Down
32 changes: 16 additions & 16 deletions test/__snapshots__/index-e2e.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ Could not find the user jakebolam on github.",
`;

exports[`All Contributors app - End to end Happy path, add correct new contributor 1`] = `
Object {
"ref": "refs/heads/all-contributors/add-jakebolam",
"sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
}
`;

exports[`All Contributors app - End to end Happy path, add correct new contributor 2`] = `
Object {
"branch": "all-contributors/add-jakebolam",
"content": "IyBBbGxDb250cmlidXRvcnNCb3QKQSBib3QgZm9yIGF1dG9tYXRpY2FsbHkgYW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2YgYW55IGtpbmQgd2VsY29tZQoKIyMgTElDRU5TRQoKW01JVF0oTElDRU5TRSkK",
Expand All @@ -40,7 +33,7 @@ Object {
}
`;

exports[`All Contributors app - End to end Happy path, add correct new contributor 3`] = `
exports[`All Contributors app - End to end Happy path, add correct new contributor 2`] = `
Object {
"branch": "all-contributors/add-jakebolam",
"content": "ewogICJwcm9qZWN0TmFtZSI6ICJib3QiLAogICJwcm9qZWN0T3duZXIiOiAiYWxsLWNvbnRyaWJ0dW9ycyIsCiAgInJlcG9UeXBlIjogImdpdGh1YiIsCiAgInJlcG9Ib3N0IjogImh0dHBzOi8vZ2l0aHViLmNvbSIsCiAgImZpbGVzIjogWwogICAgIlJFQURNRS5tZCIKICBdLAogICJpbWFnZVNpemUiOiAxMDAsCiAgImNvbW1pdCI6IGZhbHNlLAogICJjb250cmlidXRvcnMiOiBbCiAgICB7CiAgICAgICJsb2dpbiI6ICJqYWtlYm9sYW0iLAogICAgICAibmFtZSI6ICJKYWtlIEJvbGFtIiwKICAgICAgImF2YXRhcl91cmwiOiAiaHR0cHM6Ly9hdmF0YXJzMi5naXRodWJ1c2VyY29udGVudC5jb20vdS8zNTM0MjM2P3Y9NCIsCiAgICAgICJwcm9maWxlIjogImh0dHBzOi8vamFrZWJvbGFtLmNvbSIsCiAgICAgICJjb250cmlidXRpb25zIjogWwogICAgICAgICJjb2RlIiwKICAgICAgICAiaW5mcmEiCiAgICAgIF0KICAgIH0KICBdLAogICJjb250cmlidXRvcnNQZXJMaW5lIjogNwp9Cg==",
Expand All @@ -49,6 +42,13 @@ Object {
}
`;

exports[`All Contributors app - End to end Happy path, add correct new contributor 3`] = `
Object {
"ref": "refs/heads/all-contributors/add-jakebolam",
"sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
}
`;

exports[`All Contributors app - End to end Happy path, add correct new contributor 4`] = `
Object {
"base": "master",
Expand All @@ -70,13 +70,6 @@ I've put up [a pull request](https://github.com/all-contributors/all-contributor
`;

exports[`All Contributors app - End to end Happy path, add correct new contributor, no allcontributors file (repo needs init first) 1`] = `
Object {
"ref": "refs/heads/all-contributors/add-jakebolam",
"sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
}
`;

exports[`All Contributors app - End to end Happy path, add correct new contributor, no allcontributors file (repo needs init first) 2`] = `
Object {
"branch": "all-contributors/add-jakebolam",
"content": "IyBBbGxDb250cmlidXRvcnNCb3QKWyFbQWxsIENvbnRyaWJ1dG9yc10oaHR0cHM6Ly9pbWcuc2hpZWxkcy5pby9iYWRnZS9hbGxfY29udHJpYnV0b3JzLTEtb3JhbmdlLnN2Zz9zdHlsZT1mbGF0LXNxdWFyZSldKCNjb250cmlidXRvcnMpCkEgYm90IGZvciBhdXRvbWF0aWNhbGx5IGFkZGluZyBhbGwtY29udHJpYnV0b3JzLiDwn6SWCgpbIVtCdWlsZF0oaHR0cHM6Ly9pbWcuc2hpZWxkcy5pby9jaXJjbGVjaS9wcm9qZWN0L2dpdGh1Yi9hbGwtY29udHJpYnV0b3JzL2FsbC1jb250cmlidXRvcnMtYm90L21hc3Rlci5zdmcpXShodHRwczovL2NpcmNsZWNpLmNvbS9naC9hbGwtY29udHJpYnV0b3JzL2FsbC1jb250cmlidXRvcnMtYm90KQpbIVtDb3ZlcmFnZV0oaHR0cHM6Ly9pbWcuc2hpZWxkcy5pby9jb2RlY292L2MvZ2l0aHViL2FsbC1jb250cmlidXRvcnMvYWxsLWNvbnRyaWJ1dG9ycy1ib3Quc3ZnKV0oaHR0cHM6Ly9jb2RlY292LmlvL2dpdGh1Yi9hbGwtY29udHJpYnV0b3JzL2FsbC1jb250cmlidXRvcnMtYm90KQpbIVtBbGwgQ29udHJpYnV0b3JzXShodHRwczovL2ltZy5zaGllbGRzLmlvL2JhZGdlL2FsbF9jb250cmlidXRvcnMtMS1vcmFuZ2Uuc3ZnKV0oI2NvbnRyaWJ1dG9ycykKWyFbQ2hhdCBvbiBTbGFja10oaHR0cHM6Ly9pbWcuc2hpZWxkcy5pby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Wl0cz9hdXRob3I9amFrZWJvbGFtICJUZXN0cyIpIHwKfCA6LS0tOiB8CjwhLS0gQUxMLUNPTlRSSUJVVE9SUy1MSVNUOkVORCAtLT4KClRoaXMgcHJvamVjdCBmb2xsb3dzIHRoZSBbYWxsLWNvbnRyaWJ1dG9yc10oaHR0cHM6Ly9naXRodWIuY29tL2FsbC1jb250cmlidXRvcnMvYWxsLWNvbnRyaWJ1dG9ycykgc3BlY2lmaWNhdGlvbi4gQ29udHJpYnV0aW9ucyBvZiBhbnkga2luZCB3ZWxjb21lCgojIyBMSUNFTlNFCgpbTUlUXShMSUNFTlNFKQo=",
Expand All @@ -85,14 +78,21 @@ Object {
}
`;

exports[`All Contributors app - End to end Happy path, add correct new contributor, no allcontributors file (repo needs init first) 3`] = `
exports[`All Contributors app - End to end Happy path, add correct new contributor, no allcontributors file (repo needs init first) 2`] = `
Object {
"branch": "all-contributors/add-jakebolam",
"content": "ewogICJwcm9qZWN0TmFtZSI6ICJhbGwtY29udHJpYnV0b3JzLWJvdCIsCiAgInByb2plY3RPd25lciI6ICJhbGwtY29udHJpYnV0b3JzIiwKICAicmVwb1R5cGUiOiAiZ2l0aHViIiwKICAicmVwb0hvc3QiOiAiaHR0cHM6Ly9naXRodWIuY29tIiwKICAiZmlsZXMiOiBbCiAgICAiUkVBRE1FLm1kIgogIF0sCiAgImltYWdlU2l6ZSI6IDEwMCwKICAiY29tbWl0IjogZmFsc2UsCiAgImNvbnRyaWJ1dG9ycyI6IFsKICAgIHsKICAgICAgImxvZ2luIjogImpha2Vib2xhbSIsCiAgICAgICJuYW1lIjogIkpha2UgQm9sYW0iLAogICAgICAiYXZhdGFyX3VybCI6ICJodHRwczovL2F2YXRhcnMyLmdpdGh1YnVzZXJjb250ZW50LmNvbS91LzM1MzQyMzY/dj00IiwKICAgICAgInByb2ZpbGUiOiAiaHR0cHM6Ly9qYWtlYm9sYW0uY29tIiwKICAgICAgImNvbnRyaWJ1dGlvbnMiOiBbCiAgICAgICAgImNvZGUiLAogICAgICAgICJkb2MiLAogICAgICAgICJpbmZyYSIKICAgICAgXQogICAgfQogIF0sCiAgImNvbnRyaWJ1dG9yc1BlckxpbmUiOiA3Cn0K",
"message": "docs: create .all-contributorsrc",
}
`;

exports[`All Contributors app - End to end Happy path, add correct new contributor, no allcontributors file (repo needs init first) 3`] = `
Object {
"ref": "refs/heads/all-contributors/add-jakebolam",
"sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
}
`;

exports[`All Contributors app - End to end Happy path, add correct new contributor, no allcontributors file (repo needs init first) 4`] = `
Object {
"base": "master",
Expand Down
Loading