-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcoverbox_functions.sh
91 lines (77 loc) · 1.88 KB
/
coverbox_functions.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function git_root () {
pushd . > /dev/null
until [ -d ".git" ] || [ "`pwd`" = "/" ] ; do cd .. ; done
if [ "`pwd`" != "/" ]
then
pwd
fi
popd > /dev/null
}
function parse_git_root () {
git_root | sed -e 's/.*\/\([^\/]*\)/(\1)/'
}
function add_remote () {
branchname=$1
git config branch.$branchname.remote origin
git config branch.$branchname.merge refs/heads/$branchname
}
function del_remote () {
branchname=$1
git config --unset branch.$branchname.remote
git config --unset branch.$branchname.merge
}
function add_track () {
branchname=$1
git config --add remote.origin.fetch +refs/heads/$branchname:refs/remotes/origin/$branchname
git fetch origin $branchname:refs/remotes/origin/$branchname
}
function del_track () {
branchname=$1
git config --unset-all remote.origin.fetch refs/heads/$branchname:refs/remotes/origin/$branchname
git branch -r -d origin/$branchname
}
function get_ref () {
branchname=$1
git ls-remote origin $branchname | sed -e "s/\\([0-f]*\\).*/\\1/"
}
function pull_project () {
branchname=$1
git fetch origin $branchname
git checkout -b $branchname `get_ref $branchname`
}
function publish () {
branchname=$1
git push origin $branchname
add_remote $branchname
add_track $branchname
}
function receive () {
branchname=$1
pull_project $branchname
add_remote $branchname
add_track $branchname
}
function rid () {
branchname=$1
git branch -d $branchname
del_remote $branchname
del_track $branchname
}
function submodule_status () {
pushd . > /dev/null
cd `git_root`
git submodule foreach "git status; true"
popd > /dev/null
}
function pull_with_submodules () {
git pull $*
pushd . > /dev/null
cd `git_root`
git submodule init
git submodule update
popd > /dev/null
}