diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/environment.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/scripts/environment.js b/scripts/environment.js index b071a484e7..9777377f19 100755 --- a/scripts/environment.js +++ b/scripts/environment.js @@ -21,4 +21,15 @@ if (pr) { console.log(`export CIRCLE_TARGET_BRANCH=${base}`); console.log(`export CIRCLE_MERGE_BASE=${mergeBase}`); }); +} else { + const head = process.env['CIRCLE_SHA1']; + for (const sha of execSync(`git rev-list --max-count=10 ${head}`).toString().trim().split('\n')) { + const base = execSync(`git branch -r --contains ${sha} origin/master origin/release-*`).toString().trim().replace(/^origin\//, ''); + if (base) { + const mergeBase = execSync(`git merge-base origin/${base} ${head}`).toString().trim(); + console.log(`export CIRCLE_TARGET_BRANCH=${base}`); + console.log(`export CIRCLE_MERGE_BASE=${mergeBase}`); + break; + } + } } |