Support branch for code generation (#883)

This commit is contained in:
Tomas Della Vedova
2019-06-18 15:46:22 +02:00
committed by delvedor
parent 456fc19c94
commit 87fb0a2996
2 changed files with 16 additions and 7 deletions

View File

@ -29,7 +29,7 @@ const apiFolder = join(esFolder, 'rest-api-spec', 'src', 'main', 'resources', 'r
const xPackFolder = join(esFolder, 'x-pack', 'plugin', 'src', 'test', 'resources', 'rest-api-spec', 'api')
function cloneAndCheckout (opts, callback) {
const { log, tag } = opts
const { log, tag, branch } = opts
withTag(tag, callback)
/**
@ -57,13 +57,19 @@ function cloneAndCheckout (opts, callback) {
if (fresh) {
clone(checkout)
} else if (opts.branch) {
checkout(true)
} else {
checkout()
}
function checkout () {
log.text = `Checking out tag '${tag}'`
git.checkout(tag, err => {
function checkout (alsoPull = false) {
if (branch) {
log.text = `Checking out branch '${branch}'`
} else {
log.text = `Checking out tag '${tag}'`
}
git.checkout(branch || tag, err => {
if (err) {
if (retry++ > 0) {
callback(new Error(`Cannot checkout tag '${tag}'`), { apiFolder, xPackFolder })
@ -71,6 +77,9 @@ function cloneAndCheckout (opts, callback) {
}
return pull(checkout)
}
if (alsoPull) {
return pull(checkout)
}
callback(null, { apiFolder, xPackFolder })
})
}