-
Notifications
You must be signed in to change notification settings - Fork 7
/
tip_config.sh
39 lines (31 loc) · 987 Bytes
/
tip_config.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
#!/bin/bash
function add_config() {
read -r remote xxx <<<$(git remote)
local uri=$(git ls-remote --get-url $remote)
uri_parser $uri
# only for gitolite running on remote server
user=$(ssh $uri_address echo-user)
branchprefix=tip/$user
git config --remove-section pushtip
git config --add pushtip.remote $remote
git config --add pushtip.branchprefix $branchprefix
}
function get_config() {
remote=$(git config --get pushtip.remote)
branchprefix=$(git config --get pushtip.branchprefix)
if [ -z "$remote" ] || [ -z "$branchprefix" ]; then
echo "Config not found, trying to get it automatically"
add_config
fi
}
function die() {
echo "ERROR: $1"
exit 1
}
get_config
if [ -z "$remote" ] || [ -z "$branchprefix" ]; then
die "Could not automatically get configuration. Set it with
git config pushtip.remote remote-name
git config pushtip.branchprefix tip/<your-user-on-remote>
"
fi