Add option to prefix the remote branch name

This commit is contained in:
Oliver Davies 2020-01-15 02:20:21 +00:00
parent 09504890ba
commit 12e4c4be77

View file

@ -1,11 +1,19 @@
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
$currentBranch = exec('git rev-parse --abbrev-ref HEAD'); $branchesToIgnore = ['develop', 'master', 'staging', 'production'];
$localBranch = exec('git rev-parse --abbrev-ref HEAD');
if (in_array($currentBranch, ['master', 'production', 'develop', 'staging'])) { if (in_array($localBranch, $branchesToIgnore)) {
print "Currently on ${currentBranch}. Aborting."; print "Currently on ${localBranch}. Aborting.";
exit(1);
exit(1);
} }
exec("git push -u origin ${currentBranch}:${currentBranch}"); if ($prefix = getenv('BRANCH_PREFIX')) {
$remoteBranch = "{$prefix}-{$localBranch}";
} else {
$remoteBranch = $localBranch;
}
exec("git push -u origin ${localBranch}:${remoteBranch}");