Accept optional branch name
There's been a recent movement to rename the "master" branch in git repositories to "main" to avoid to potentially problematic word "master". Our `merge-branch` script was hard coded to "master". This PR makes it possible to pass in the name of the branch you wish to merge to. I've defaulted it to "master" for now, but I expect in time this will change.
This commit is contained in:
parent
f252ba46d1
commit
69a95f60ea
1 changed files with 9 additions and 3 deletions
|
@ -1,14 +1,20 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
main_branch="master"
|
||||||
|
|
||||||
|
if [ $# -gt 0 ]; then
|
||||||
|
main_branch=$1
|
||||||
|
fi
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
git fetch origin
|
git fetch origin
|
||||||
line_count=$(git diff origin/master..master | wc -l)
|
line_count=$(git diff origin/$main_branch..$main_branch | wc -l)
|
||||||
|
|
||||||
if [ $line_count -gt 0 ]; then
|
if [ $line_count -gt 0 ]; then
|
||||||
printf "failed: master is not up to date with origin/master\n"
|
printf "failed: $main_branch is not up to date with origin/$main_branch\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git checkout master
|
git checkout $main_branch
|
||||||
git merge "@{-1}"
|
git merge "@{-1}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue