Mining software...
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

51 рядки
2.1 KiB

  1. #!/usr/bin/env bash
  2. # Disallow pull requests to `fireice-uk/xmr-stak` branch `master`
  3. #
  4. # - merging from `dev` or `release-...` located within our reposetory is allowed
  5. # - merging to `master` within a fork is allowed
  6. # - pull request to `dev` are allowed from everywhere
  7. #
  8. # See: https://docs.travis-ci.com/user/environment-variables/
  9. # https://developer.github.com/v3/pulls/#get-a-single-pull-request
  10. #
  11. #
  12. # return 0 = OK, else false
  13. #
  14. if [ "$TRAVIS" != "true" ] ; then
  15. echo "Not in travis, so I have nothing to do :)"
  16. else
  17. xmrstak_slug="fireice-uk/xmr-stak"
  18. # check only pull requests to `master`
  19. if [ "$TRAVIS_EVENT_TYPE" == "pull_request" ] && [ "$TRAVIS_BRANCH" == "master" ] ; then
  20. # allow pull requests to forks
  21. if [ "$TRAVIS_REPO_SLUG" == "$xmrstak_slug" ] ; then
  22. echo "$TRAVIS_PULL_REQUEST_BRANCH" | grep -q "^dev$"
  23. comingFromDev=$?
  24. echo "$TRAVIS_PULL_REQUEST_BRANCH" | grep -q "^release-"
  25. comingFromRelease=$?
  26. # check origin
  27. if [[ "$TRAVIS_PULL_REQUEST_SLUG" != "$xmrstak_slug" || ( $comingFromDev -ne 0 && $comingFromRelease -ne 0 ) ]] ; then
  28. # the PR came from a fork owned by the first part of the slug
  29. pr_author=$(echo "$TRAVIS_PULL_REQUEST_SLUG" | awk -F "/" '{print $1}')
  30. pr_branch=$TRAVIS_PULL_REQUEST_BRANCH
  31. echo ""
  32. echo "Pull request opened to wrong branch!"
  33. echo ""
  34. echo "Pul requests need to go to our 'dev' branch but your pull-request from '"$TRAVIS_PULL_REQUEST_SLUG"' was"
  35. echo "sent to 'master' which is only updated by our maintainers for new stable releases."
  36. echo ""
  37. echo "Please re-open your pull-request against our 'dev' branch:"
  38. echo " https://github.com/fireice-uk/xmr-stak/compare/dev...$pr_author:$pr_branch?expand=1"
  39. echo ""
  40. echo "For further information, please see:"
  41. echo " https://github.com/fireice-uk/xmr-stak/blob/dev/CONTRIBUTING.md"
  42. exit 1
  43. fi
  44. fi
  45. fi
  46. fi