merge-pr.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. #
  3. # Copyright © 2016 Zetok Zalbavar <zetok@openmailbox.org>
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. # Script for merging pull requests. Works only when there are no merge
  18. # conflicts. Assumes that working dir is a qTox git repo.
  19. #
  20. # Requires SSH key that github accepts and GPG set to sign merge commits.
  21. # usage:
  22. # ./$script $pr_number $optional_message
  23. #
  24. #
  25. # $pr_number – number of the PR as shown on GH
  26. # $optional_message – message that is going to be put in merge commit,
  27. # before the appended shortlog.
  28. #
  29. set -e -o pipefail
  30. readonly PR=$1
  31. # make sure to add newlines to the message, otherwise merge message
  32. # will not look well
  33. if [[ ! -z $2 ]]
  34. then
  35. readonly OPT_MSG="
  36. $2
  37. "
  38. fi
  39. source_functions() {
  40. local fns_file="tools/lib/PR_bash.source"
  41. source $fns_file
  42. }
  43. main() {
  44. local remote_name="upstream"
  45. local merge_branch="merge"
  46. source_functions
  47. exit_if_not_pr $PR
  48. add_remote
  49. get_sources
  50. merge git merge -S \
  51. && after_merge_msg $merge_branch \
  52. || after_merge_failure_msg $merge_branch
  53. }
  54. main