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