Skip to content

Commit

Permalink
use git instead of gitdata
Browse files Browse the repository at this point in the history
  • Loading branch information
mfix22 committed Oct 20, 2020
1 parent 2ffeaa0 commit ccf7492
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/pull/merged.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports.deleteBranch = () => async (context) => {

return executeAction(action, {
[DELETE_BRANCH]: () => {
return context.github.gitdata
return context.github.git
.deleteRef(context.repo({ ref: `heads/${thread.head.ref}` }))
.catch((e) => {
// TODO this is because GitHub has already deleted the reference
Expand Down Expand Up @@ -95,7 +95,7 @@ module.exports.createTag = () => async (context) => {

const sha = thread.merge_commit_sha

await context.github.gitdata.createTag(
await context.github.git.createTag(
context.repo({
tag,
type: 'commit',
Expand All @@ -104,7 +104,7 @@ module.exports.createTag = () => async (context) => {
})
)

await context.github.gitdata.createRef(
await context.github.git.createRef(
context.repo({
ref: `refs/tags/${tag}`,
sha,
Expand Down
14 changes: 7 additions & 7 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ beforeEach(async () => {
},
}),
},
gitdata: {
git: {
deleteRef: jest.fn().mockResolvedValue(),
createRef: jest.fn().mockResolvedValue(),
createTag: jest.fn().mockResolvedValue(),
Expand Down Expand Up @@ -662,7 +662,7 @@ describe('pull_request', () => {
test('Can delete branches after merging', async () => {
await robot.receive(mergedPayload())

expect(github.gitdata.deleteRef).toHaveBeenCalledWith({
expect(github.git.deleteRef).toHaveBeenCalledWith({
owner: 'Codertocat',
ref: 'heads/mfix22-patch-1',
repo: 'Hello-World',
Expand All @@ -673,7 +673,7 @@ describe('pull_request', () => {
await robot.receive(mergedPayload({ repo: null }))
await robot.receive(mergedPayload({ repo: { fork: true } }))

expect(github.gitdata.deleteRef).not.toHaveBeenCalled()
expect(github.git.deleteRef).not.toHaveBeenCalled()
})

test.each([
Expand All @@ -687,15 +687,15 @@ describe('pull_request', () => {

const sha = 'a244454d959a49f53aa60768d117d3eeaa0c552e'

expect(github.gitdata.createTag).toHaveBeenCalledWith({
expect(github.git.createTag).toHaveBeenCalledWith({
owner: 'Codertocat',
repo: 'Hello-World',
message: 'Update README.md (#3)',
type: 'commit',
object: sha,
tag,
})
expect(github.gitdata.createRef).toHaveBeenCalledWith({
expect(github.git.createRef).toHaveBeenCalledWith({
owner: 'Codertocat',
repo: 'Hello-World',
ref: `refs/tags/${tag}`,
Expand All @@ -707,8 +707,8 @@ describe('pull_request', () => {
await robot.receive(mergedPayload({ labels: ['Major'], base: 'docs' }))
await wait(2)

expect(github.gitdata.createTag).not.toHaveBeenCalled()
expect(github.gitdata.createRef).not.toHaveBeenCalled()
expect(github.git.createTag).not.toHaveBeenCalled()
expect(github.git.createRef).not.toHaveBeenCalled()
})

test.each(['opened', 'synchronize'])(
Expand Down

0 comments on commit ccf7492

Please sign in to comment.