From 1d64687d13ff112c56e1f345a0b4c81a531aed19 Mon Sep 17 00:00:00 2001 From: Nitin A Kamble Date: Tue, 8 Jun 2010 22:04:59 -0700 Subject: update create_pull_request for distro/master With this change the create_pull_request will be able to generate pull requests to master as well as distro/master branch. Some documentation is added in the Usage messange of the script. Signed-off-by: Nitin A Kamble --- scripts/create-pull-request | 77 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 16 deletions(-) (limited to 'scripts/create-pull-request') diff --git a/scripts/create-pull-request b/scripts/create-pull-request index 2223151956..e8d4115e87 100755 --- a/scripts/create-pull-request +++ b/scripts/create-pull-request @@ -4,38 +4,83 @@ # usage() { - echo "Error: Invalid arguments." echo "Usage: " - echo "$ $0 " + echo "$ $0 [-r ] [-i ] -b " + echo " is a commit identifier, like branch-name, HEAD, hex-commit-id" echo " is a commit identifier, like branch-name, HEAD, hex-commit-id" echo " is the branch-name in the git.pokylinux.org/poky-contrib tree" + echo " If is not specified then relative to master is assumed" + echo " If is not specified then it is assumed as HEAD" + echo " For Example:" + echo " $0 -r master -i misc -b nitin/misc " + echo " $0 -b nitin/misc " + echo " $0 -r distro/master -i nitin/distro -b nitin/distro " exit 1 } -case $# in - 2) - COMMIT=$1 - CONTRIB_BRANCH=$2 - shift - ;; +while [ $# -ne 0 ] # loop over arguments +do + + case $1 in + -r ) + shift + RELATIVE_TO=$1 + shift + ;; + -i ) + shift + COMMIT_ID=$1 + shift + ;; + -b ) + shift + CONTRIB_BRANCH=$1 + shift + ;; *) + usage + ;; + esac +done + +if [ "${COMMIT_ID}" = "" ]; then + COMMIT_ID=HEAD + echo "Note: parameter assumed as 'HEAD'" +fi + +if [ "${RELATIVE_TO}" = "" ]; then + RELATIVE_TO=master + echo "Note: parameter assumed as 'master'" +fi + +if [ "${CONTRIB_BRANCH}" = "" ]; then + echo: "Error: Parameter not specified" usage - ;; -esac +fi -if [ "$COMMIT" = "" ]; then +git --no-pager show ${COMMIT_ID} > /dev/null +if [ "$?" != "0" ]; then + echo "Error: Invalid parameter specified" usage fi -git --no-pager show $COMMIT > /dev/null +git --no-pager show ${RELATIVE_TO} > /dev/null if [ "$?" != "0" ]; then - echo "Invalid Commit." + echo "Error: Invalid parameter specified: ${RELATIVE_TO}" usage fi -git --no-pager diff master..${COMMIT} | diffstat -p1 echo "" -git --no-pager log --no-merges master..${COMMIT} | git --no-pager shortlog +git --no-pager diff ${RELATIVE_TO}..${COMMIT_ID} | diffstat -p1 +echo "" +git --no-pager log --no-merges ${RELATIVE_TO}..${COMMIT_ID} | git --no-pager shortlog +PULL_URL="http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=${CONTRIB_BRANCH}" -echo "Pull URL: http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=${CONTRIB_BRANCH}" +echo "Pull URL: ${PULL_URL}" + +wget -q ${PULL_URL} -O - | grep -q "Invalid branch:\ ${CONTRIB_BRANCH}" +if [ "$?" == "0" ]; then + echo "Warning: Branch named '${CONTRIB_BRANCH}' was not found on contrib git tree" + echo "Check your parameter" +fi -- cgit 1.2.3-korg