-
Notifications
You must be signed in to change notification settings - Fork 7
/
git-pushtip
executable file
·62 lines (49 loc) · 1.48 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
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/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.
CONFIGURATION
The following options are retrieved from git configuration:
pushtip.remote
Points to the remote repository to be used. If there's no remote
configured it will try to discover it using gitolite as remote
server
pushtip.branchprefix
Prefix to be used in branches pushed for review. This is usually
tip/<your-username>
" 1>&$1
}
OPT_WIP=0
pushargs=""
args=
for arg in "$@"; do
case "$arg" in
-w) OPT_WIP=1
;;
-h) usage 1
exit 0
;;
# unknown options go to arguments to git-push
-*) pushargs="$pushargs $arg"
;;
*) args="$args $arg"
;;
esac
done
IFS=' ' read -a args <<< "$args"
. $SCRIPT_DIR/uri_parser.sh
. $SCRIPT_DIR/tip_config.sh
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