merge_base_branch.sh 939 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env bash
  2. set -ex
  3. if [[ "$BUILDKITE_BRANCH" =~ ^(develop|master|dinsic|shhs|release-.*)$ ]]; then
  4. echo "Not merging forward, as this is a release branch"
  5. exit 0
  6. fi
  7. if [[ -z $BUILDKITE_PULL_REQUEST_BASE_BRANCH ]]; then
  8. echo "Not a pull request, or hasn't had a PR opened yet..."
  9. # It probably hasn't had a PR opened yet. Since all PRs land on develop, we
  10. # can probably assume it's based on it and will be merged into it.
  11. GITBASE="develop"
  12. else
  13. # Get the reference, using the GitHub API
  14. GITBASE=$BUILDKITE_PULL_REQUEST_BASE_BRANCH
  15. fi
  16. # Show what we are before
  17. git --no-pager show -s
  18. # Set up username so it can do a merge
  19. git config --global user.email bot@matrix.org
  20. git config --global user.name "A robot"
  21. # Fetch and merge. If it doesn't work, it will raise due to set -e.
  22. git fetch -u origin $GITBASE
  23. git merge --no-edit origin/$GITBASE
  24. # Show what we are after.
  25. git --no-pager show -s