-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc_git
65 lines (55 loc) · 1.87 KB
/
.bashrc_git
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
### ALIASES
# attention! there can be problems if you have Ghostscript installed
alias gs='git status'
alias gt='git checkout'
alias gl='git log --oneline'
alias gd='git diff'
alias gb='git branch'
alias gba='git branch -a'
alias gcp='git cherry-pick'
# mistyping
alias gti='git'
alias got='git'
### FUNCTIONS
# get current branch pull it and than push everything in it
gipp() {
branch_name=`git branch | grep \* | cut -d ' ' -f2-`
echo "Update branch:${branch_name}"
git pull origin ${branch_name} || exit 1
echo "Push all commits"
git push origin ${branch_name}
}
# look for the latest release (for branch names origin/releases/1.2.3)
## arg1: prefix [default=""] (for branch names origin/releases/prefix_1.2.3)
latest_release() {
prefix=${1:-""}
git branch -a | egrep "origin/releases/[0-9]+" | awk '{n=split($1,arr,"/"); n=split(arr[n],arr,"."); multiplier=1; res=0; for(i=n; i>=1; i--) { res=res + arr[i]*multiplier; multiplier=multiplier*1000;} print res "\t" $1}' | sort -rnk1 | head -n1 | cut -f2 | sed 's%^remotes/%%g'
}
# look for every jira tasks between current branch and master (it is neccessary that task id is part of commit message)
## arg1: prefix [default=""] (goto latest_release())
find_connected_tasks() {
prefix=${1:-""}
git log --oneline $( latest_release ${prefix} )..origin/master | grep -E '\w+\-[0-9]+' -o | sort -u | awk '{r=r " " $1; next} END {print substr(r,2,length(r))}'
}
# add and push new tag
## arg1: tagname
gtag() {
tagname=$1
if [ -z $tagname ]
then
echo "no tagname provided"
fi
git tag $tagname
git push origin --tags
}
# "rename" tag: write new tag over the old one and remove old tag
## arg1: old tagname
## arg2: new tagname
tagrename() {
old_tag=$1
new_tag=$2
git tag $new_tag $old_tag
git tag -d $old_tag
git push origin :refs/tags/$old_tag
git push --tags
}