Skip to content

Commit

Permalink
chore(tools): allow merging PR to whatever branch is checked out
Browse files Browse the repository at this point in the history
Useful for either dev testing or merging PRs to dev branches. Also stop
updating local repo state beyond merging the PR.
  • Loading branch information
anthonybilinski committed Oct 10, 2019
1 parent e97b270 commit fe9d83d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
4 changes: 3 additions & 1 deletion MAINTAINING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ git config --global alias.logs 'log --show-signature'
merge-commit **must** be signed. To simplify the process, and ensure that
things are done "right", it's preferable to use the [`merge-pr.sh`] script,
which does that for you automatically.
- **use** [`merge-pr.sh`] script to merge PRs, e.g. `./merge-pr.sh 1234`.
- **use** [`merge-pr.sh`] script to merge PRs. First checkout the target
branch, usually either `master` or a release dev branch e.g. `v1.17-dev`,
make sure it's up to date with qTox/qTox, then e.g. `./merge-pr.sh 1234`.

You don't have to use it, but then you're running into risk of breaking
travis build of master & other PRs, since it verifies all commit messages,
Expand Down
3 changes: 3 additions & 0 deletions merge-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ source_functions() {
main() {
local remote_name="upstream"
local merge_branch="merge"
local base_branch # because assigning on the same line will break error code parsing.. http://www.tldp.org/LDP/abs/html/localvar.html
base_branch=$(git symbolic-ref HEAD --short)

source_functions
exit_if_not_pr $PR
add_remote
Expand Down
21 changes: 9 additions & 12 deletions tools/lib/PR_bash.source
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,24 @@ add_remote() {
after_merge_msg() {
echo ""
echo "PR #$PR was merged into «$@$PR» branch."
echo "To compare with master:"
echo "To compare with $base_branch:"
echo ""
echo " git diff master..$@$PR"
echo " git diff $base_branch..$@$PR"
echo ""
if [[ "$@" == "merge" ]]
then
echo "To push that to master on github:"
echo "To push that to $base_branch on github:"
echo ""
echo " git checkout master && git merge --ff $@$PR && git push upstream master"
echo " git checkout $base_branch && git merge --ff $@$PR && git push upstream $base_branch"
echo ""
echo "After pushing to master, delete branches:"
echo "After pushing to $base_branch, delete branches:"
echo ""
echo " git branch -d {$@,}$PR"
echo ""
fi
echo "To discard any changes:"
echo ""
echo " git checkout master && git branch -D {$@,}$PR"
echo " git checkout $base_branch && git branch -D {$@,}$PR"
echo ""
}

Expand All @@ -88,7 +88,7 @@ after_merge_failure_msg() {
echo ""
echo "You may want to remove not merged branches, if they exist:"
echo ""
echo " git checkout master && git branch -D {$@,}$PR"
echo " git checkout $base_branch && git branch -D {$@,}$PR"
echo ""
}

Expand All @@ -100,16 +100,13 @@ rm_obsolete_branch() {
get_sources() {
add_remote
rm_obsolete_branch
git fetch $remote_name && \
git checkout master && \
git rebase $remote_name/master master && \
git fetch $remote_name pull/$PR/head:$PR && \
git checkout master -b $merge_branch$PR
git checkout $base_branch -b $merge_branch$PR
}

# check whether to sign
merge() {
"${@}" --no-ff $PR -m "Merge pull request #$PR
$OPT_MSG
$(git shortlog master..$PR)"
$(git shortlog $base_branch..$PR)"
}

0 comments on commit fe9d83d

Please sign in to comment.