-
Notifications
You must be signed in to change notification settings - Fork 0
/
refresh.sh
executable file
·56 lines (46 loc) · 1.12 KB
/
refresh.sh
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
#!/bin/sh
DEFAULT_BRANCH=main
BRANCH=${DEFAULT_BRANCH}
CMD=$(basename $0)
usage(){
cat << EOT
Refresh local repository from github.
The script optionally accepts one argument: the name of the repository barnch.
Default branch is '${DEFAULT_BRANCH}'.
To see what branches are valid on github, check them using 'git branch'.
usage:
$ ${CMD} -b [reponame]
or
$ ${CMD} --branch [reponame]
EOT
}
while [ $# -ge 1 ]
do
ARG=$1
case $ARG in
-h | --help)
usage
exit 0
;;
-b | --branch)
BRANCH=$2
if [ -z ${BRANCH} ]
then
cat << EOR
ERROR: ${ARG} requires string parameter as the name of repository branch.
Mandatory argument is missing. See usage (-h or --help) for further information.
EOR
exit 1
fi
echo "Refreshing '${BRANCH}' ..."
git pull origin ${BRANCH}
exit 0
;;
*)
usage
exit 1
;;
esac
shift
done
git pull origin ${BRANCH}