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

@ -3,7 +3,7 @@ const fs = require('fs')
const path = require('path')
const childProcess = require('child_process')
const GitHubApi = require('github')
const { GitProcess } = require('dugite')
const { getCurrentBranch } = require('./lib/utils.js')
const request = require('request')
const semver = require('semver')
const rootPackageJson = require('../package.json')
@ -162,21 +162,3 @@ new Promise((resolve, reject) => {
console.error(`Error: ${err}`)
process.exit(1)
})
async function getCurrentBranch () {
const gitDir = path.resolve(__dirname, '..')
console.log(`Determining current git branch`)
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(`Successfully determined current git branch is ` +
`${currentBranch}`)
return currentBranch
} else {
const error = GitProcess.parseError(branchDetails.stderr)
console.log(`Could not get details for the current branch,
error was ${branchDetails.stderr}`, error)
process.exit(1)
}
}