-
Notifications
You must be signed in to change notification settings - Fork 26
/
git-cms-fetch-pr
executable file
·61 lines (52 loc) · 1.13 KB
/
git-cms-fetch-pr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /bin/bash
function usage() {
cat <<@EOF
Usage: git cms-fetch-pr <pull request> [<local branch>]
Description:
Fetch a pull request from https://github.com/cms-sw/cmssw.git into the local branch
pull/<pull request> , or <local branch> if specified.
@EOF
exit $1
}
PULL=
BRANCH=
while [ "$#" != 0 ]; do
case "$1" in
-*)
echo Unknown option $1
usage 1
;;
*)
if [ "$PULL" == "" ]; then
PULL=$1
elif [ "$BRANCH" == "" ]; then
BRANCH=$1
else
echo Unexpected argument $1
usage 1
fi
shift
;;
esac
done
# initialize the local repository
if [ -z "$CMSSW_BASE" ]; then
echo "CMSSW environment not setup, please run 'cmsenv' before 'git cms-fetch-pr'."
exit 1
fi
if ! [ -d "$CMSSW_BASE"/src/.git ]; then
cd $CMSSW_BASE/src
git cms-init --upstream-only
fi
if [[ $PULL =~ .*:.* ]]; then
USER=$(echo "$PULL" | cut -d: -f1)
PULL=$(echo "$PULL" | cut -d: -f2)
else
USER="cms-sw"
fi
REMOTE="git@github.com:$USER/cmssw.git"
if [ -z "$BRANCH"]; then
BRANCH="pull/$PULL"
fi
cd $CMSSW_BASE/src
git fetch -n $REMOTE refs/pull/$PULL/head:$BRANCH