merge_base_branch.sh 989 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env bash
  2. set -e
  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. echo "--- merge_base_branch $GITBASE"
  17. # Show what we are before
  18. git --no-pager show -s
  19. # Set up username so it can do a merge
  20. git config --global user.email bot@matrix.org
  21. git config --global user.name "A robot"
  22. # Fetch and merge. If it doesn't work, it will raise due to set -e.
  23. git fetch -u origin $GITBASE
  24. git merge --no-edit --no-commit origin/$GITBASE
  25. # Show what we are after.
  26. git --no-pager show -s