1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

chore(tools): allow merging PR to whatever branch is checked out

Useful for either dev testing or merging PRs to dev branches. Also stop
updating local repo state beyond merging the PR.
This commit is contained in:
Anthony Bilinski 2019-09-14 12:19:18 -07:00
parent e97b270584
commit fe9d83d881
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
3 changed files with 15 additions and 13 deletions

View File

@ -58,7 +58,9 @@ git config --global alias.logs 'log --show-signature'
merge-commit **must** be signed. To simplify the process, and ensure that 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, things are done "right", it's preferable to use the [`merge-pr.sh`] script,
which does that for you automatically. 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 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, travis build of master & other PRs, since it verifies all commit messages,

View File

@ -52,6 +52,9 @@ source_functions() {
main() { main() {
local remote_name="upstream" local remote_name="upstream"
local merge_branch="merge" 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 source_functions
exit_if_not_pr $PR exit_if_not_pr $PR
add_remote add_remote

View File

@ -60,24 +60,24 @@ add_remote() {
after_merge_msg() { after_merge_msg() {
echo "" echo ""
echo "PR #$PR was merged into «$@$PR» branch." echo "PR #$PR was merged into «$@$PR» branch."
echo "To compare with master:" echo "To compare with $base_branch:"
echo "" echo ""
echo " git diff master..$@$PR" echo " git diff $base_branch..$@$PR"
echo "" echo ""
if [[ "$@" == "merge" ]] if [[ "$@" == "merge" ]]
then then
echo "To push that to master on github:" echo "To push that to $base_branch on github:"
echo "" 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 ""
echo "After pushing to master, delete branches:" echo "After pushing to $base_branch, delete branches:"
echo "" echo ""
echo " git branch -d {$@,}$PR" echo " git branch -d {$@,}$PR"
echo "" echo ""
fi fi
echo "To discard any changes:" echo "To discard any changes:"
echo "" echo ""
echo " git checkout master && git branch -D {$@,}$PR" echo " git checkout $base_branch && git branch -D {$@,}$PR"
echo "" echo ""
} }
@ -88,7 +88,7 @@ after_merge_failure_msg() {
echo "" echo ""
echo "You may want to remove not merged branches, if they exist:" echo "You may want to remove not merged branches, if they exist:"
echo "" echo ""
echo " git checkout master && git branch -D {$@,}$PR" echo " git checkout $base_branch && git branch -D {$@,}$PR"
echo "" echo ""
} }
@ -100,16 +100,13 @@ rm_obsolete_branch() {
get_sources() { get_sources() {
add_remote add_remote
rm_obsolete_branch 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 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 # check whether to sign
merge() { merge() {
"${@}" --no-ff $PR -m "Merge pull request #$PR "${@}" --no-ff $PR -m "Merge pull request #$PR
$OPT_MSG $OPT_MSG
$(git shortlog master..$PR)" $(git shortlog $base_branch..$PR)"
} }