Skip to content

Commit

Permalink
feat: get diff from conflicted branchs
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoDinizMonteiro committed Jan 26, 2023
1 parent fbf5555 commit c284eba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,19 @@ async function createBranch(branchName, commitSha) {
})
}

async function conflictDetails(base, head) {
const res = await octokit.request('GET /repos/{owner}/{repo}/compare/{basehead}{?page,per_page}', {
...repoInfo,
basehead: `${base}...${head}`
})
console.log(res);
}


module.exports = {
recreateDeployBranch,
getLastCommitSha,
conflictDetails,
createAuxBranch,
deleteBranch,
mergeBranchs,
Expand Down
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { getLastCommitSha, createAuxBranch, deleteBranch, getPrs, mergeBranchs, recreateDeployBranch } = require('./helper')
const { getLastCommitSha, createAuxBranch, deleteBranch, getPrs, mergeBranchs, recreateDeployBranch, conflictDetails } = require('./helper')

async function run() {
const baseLastCommit = await getLastCommitSha()
Expand All @@ -7,17 +7,22 @@ async function run() {

const pullRequests = await getPrs()

let lastBranchToMerge
try {
let lastMergeCommitSha
for (let pull of pullRequests) {
console.log(`Merging PR ${pull.number}`)
lastBranchToMerge = pull.head.ref

const { data } = await mergeBranchs(pull.head.ref)

console.log(`Successful merge PR ${pull.number}`);

lastMergeCommitSha = data.sha
}
await recreateDeployBranch(lastMergeCommitSha)
} catch(error) {
await conflictDetails(workBranchName, lastBranchToMerge)
} finally {
await deleteBranch(workBranchName)
}
Expand Down

0 comments on commit c284eba

Please sign in to comment.