test-pr.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/env 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 testing pull requests. Works only when there are no merge
  18. # conflicts. Assumes that working dir is a qTox git repo.
  19. #
  20. # usage:
  21. # ./$script $pr_number $optional_message
  22. #
  23. #
  24. # $pr_number – number of the PR as shown on GH
  25. # $optional_message – message that is going to be put in merge commit,
  26. # before the appended shortlog.
  27. #
  28. set -e -o pipefail
  29. readonly PR=$1
  30. # make sure to add newlines to the message, otherwise merge message
  31. # will not look well
  32. if [[ ! -z $2 ]]
  33. then
  34. readonly OPT_MSG="
  35. $2
  36. "
  37. fi
  38. source_functions() {
  39. local fns_file="tools/lib/PR_bash.source"
  40. source $fns_file
  41. }
  42. main() {
  43. local remote_name="upstream"
  44. local merge_branch="test"
  45. source_functions
  46. exit_if_not_pr $PR
  47. add_remote "https"
  48. get_sources
  49. merge git -c user.email='<>' -c user.name='qTox testing' \
  50. merge --no-gpg-sign \
  51. && after_merge_msg $merge_branch \
  52. || after_merge_failure_msg $merge_branch
  53. }
  54. main