chore: move getCurrentBranch to a util file (#15921)

* chore: move getCurrentBranch to a util file

* fix import
This commit is contained in:
Shelley Vohr 2018-12-03 13:28:10 -08:00 committed by GitHub
parent a1a431eb87
commit d3c58ea48c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 53 deletions

View file

@ -10,6 +10,7 @@ const args = require('minimist')(process.argv.slice(2), {
})
const { execSync } = require('child_process')
const { GitProcess } = require('dugite')
const { getCurrentBranch } = require('./lib/utils.js')
const GitHub = require('github')
const path = require('path')
@ -27,18 +28,6 @@ function getLastBumpCommit (tag) {
return JSON.parse(data)
}
async function getCurrentBranch (gitDir) {
const gitArgs = ['rev-parse', '--abbrev-ref', 'HEAD']
const branchDetails = await GitProcess.exec(gitArgs, gitDir)
if (branchDetails.exitCode === 0) {
return branchDetails.stdout.trim()
}
const error = GitProcess.parseError(branchDetails.stderr)
console.error(`${fail} couldn't get current branch: `, error)
process.exit(1)
}
async function revertBumpCommit (tag) {
const branch = await getCurrentBranch()
const commitToRevert = getLastBumpCommit(tag).hash