Skip to content

Commit

Permalink
build: get current release branch from commit (#18834)
Browse files Browse the repository at this point in the history
* chore: get current release branch from commit

* love too lint
  • Loading branch information
trop[bot] authored and codebytere committed Jun 17, 2019
1 parent 7a135c7 commit 07cd1e6
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions script/lib/utils.js
Expand Up @@ -24,20 +24,27 @@ function getAbsoluteElectronExec () {
return path.resolve(__dirname, '../../..', getElectronExec())
}

async function getCurrentBranch (gitDir) {
const gitArgs = ['rev-parse', '--abbrev-ref', 'HEAD']
const branchDetails = await GitProcess.exec(gitArgs, gitDir)
if (branchDetails.exitCode === 0) {
const currentBranch = branchDetails.stdout.trim()
console.log(`${pass} current git branch is: ${currentBranch}`)
return currentBranch
async function handleGitCall (args, gitDir) {
const details = await GitProcess.exec(args, gitDir)
if (details.exitCode === 0) {
return details.stdout.trim()
} else {
const error = GitProcess.parseError(branchDetails.stderr)
console.log(`${fail} couldn't get details current branch: `, error)
const error = GitProcess.parseError(details.stderr)
console.log(`${fail} couldn't parse git process call: `, error)
process.exit(1)
}
}

async function getCurrentBranch (gitDir) {
let branch = await handleGitCall(['rev-parse', '--abbrev-ref', 'HEAD'], gitDir)
if (!branch.match(/[0-9]+-[0-9]+-x/)) {
const lastCommit = await handleGitCall(['rev-parse', 'HEAD'], gitDir)
const branches = (await handleGitCall(['branch', '--contains', lastCommit], gitDir)).split('\n')
branch = branches.filter(b => b.match(/[0-9]+-[0-9]+-x/))[0].trim()
}
return branch
}

module.exports = {
getCurrentBranch,
getElectronExec,
Expand Down

0 comments on commit 07cd1e6

Please sign in to comment.