forked from lucasdemarchi/toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-pushtip
executable file
·49 lines (40 loc) · 1.09 KB
/
git-pushtip
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
#!/bin/bash
SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
usage() {
echo "
Usage: $(basename $0) [OPTIONS] [BRANCH]
Send a branch for review in tip/ or wip/ namespaces.
OPTIONS
-w consider this a WIP. The branch prefix will be wip/
-h display this help message
All the unknown options are passed directly to the git-push command.
" 1>&2;
exit 1;
}
. $SCRIPT_DIR/uri_parser.sh
. $SCRIPT_DIR/tip_config.sh
OPT_WIP=0
pushargs=""
args=
for arg in "$@"; do
case "$arg" in
-w) OPT_WIP=1
;;
-h) usage
;;
# unknown options go to arguments to git-push
-*) pushargs="$pushargs $arg"
;;
*) args="$args $arg"
;;
esac
done
IFS=' ' read -a args <<< "$args"
TIP=${args[0]:-HEAD}
BRANCH=$(basename $(git rev-parse --abbrev-ref --symbolic $TIP))
if [ -z "$BRANCH" ]; then
die "No branch matches '$TIP'"
fi
[ $OPT_WIP -eq 1 ] && branchprefix=${branchprefix/tip/wip}
echo " Using $remote/$branchprefix as namespace"
git push --set-upstream $pushargs $remote $TIP:$branchprefix/$BRANCH