create-pull-request 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/bash
  2. #
  3. # create a pull request for your branch
  4. #
  5. usage() {
  6. echo "Usage: "
  7. echo "$ $0 [-r <relative_to>] [-i <commit_id>] -b <contrib_branch>"
  8. echo " <relative_to> is a commit identifier, like branch-name, HEAD, hex-commit-id"
  9. echo " <commit_id> is a commit identifier, like branch-name, HEAD, hex-commit-id"
  10. echo " <contrib_branch> is the branch-name in the git.pokylinux.org/poky-contrib tree"
  11. echo " If <relative_to> is not specified then relative to master is assumed"
  12. echo " If <commit_id> is not specified then it is assumed as HEAD"
  13. echo " For Example:"
  14. echo " $0 -r master -i misc -b nitin/misc "
  15. echo " $0 -b nitin/misc "
  16. echo " $0 -r distro/master -i nitin/distro -b nitin/distro "
  17. exit 1
  18. }
  19. while [ $# -ne 0 ] # loop over arguments
  20. do
  21. case $1 in
  22. -r )
  23. shift
  24. RELATIVE_TO=$1
  25. shift
  26. ;;
  27. -i )
  28. shift
  29. COMMIT_ID=$1
  30. shift
  31. ;;
  32. -b )
  33. shift
  34. CONTRIB_BRANCH=$1
  35. shift
  36. ;;
  37. *)
  38. usage
  39. ;;
  40. esac
  41. done
  42. if [ "${COMMIT_ID}" = "" ]; then
  43. COMMIT_ID=HEAD
  44. echo "Note: <commit_id> parameter assumed as 'HEAD'"
  45. fi
  46. if [ "${RELATIVE_TO}" = "" ]; then
  47. RELATIVE_TO=master
  48. echo "Note: <relative_to> parameter assumed as 'master'"
  49. fi
  50. if [ "${CONTRIB_BRANCH}" = "" ]; then
  51. echo "Error: Parameter <contrib_branch> not specified"
  52. usage
  53. fi
  54. git --no-pager show ${COMMIT_ID} > /dev/null
  55. if [ "$?" != "0" ]; then
  56. echo "Error: Invalid <commit_id> parameter specified"
  57. usage
  58. fi
  59. git --no-pager show ${RELATIVE_TO} > /dev/null
  60. if [ "$?" != "0" ]; then
  61. echo "Error: Invalid <relative_to> parameter specified: ${RELATIVE_TO}"
  62. usage
  63. fi
  64. echo ""
  65. git --no-pager diff ${RELATIVE_TO}..${COMMIT_ID} | diffstat -p1
  66. echo ""
  67. git --no-pager log --no-merges ${RELATIVE_TO}..${COMMIT_ID} | git --no-pager shortlog
  68. PULL_URL="http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=${CONTRIB_BRANCH}"
  69. echo "Pull URL: ${PULL_URL}"
  70. wget -q ${PULL_URL} -O - | grep -q "Invalid branch:\ ${CONTRIB_BRANCH}"
  71. if [ "$?" == "0" ]; then
  72. echo "Warning: Branch named '${CONTRIB_BRANCH}' was not found on contrib git tree"
  73. echo "Check your <contrib-branch> parameter"
  74. fi