-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_aliases
128 lines (110 loc) · 3.32 KB
/
.bash_aliases
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Get current branch name
get_branch_name() {
echo $(git symbolic-ref --short -q HEAD)
}
# Upgrade packages
aptupupgrade() {
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
}
# Clean environment.
function clean() {
find ./ -name '*.pyc' -exec rm -rf {} \;
find ./ -name '__pycache__' -print0 | xargs -0 rm -rf;
rm -rf ./xunit* ./.coverage* ./.pytest_cache ./*artifacts.tar.gz;
truncate -s0 log/voipgrid*.log
find ./ -name '*.py.py' -delete;
find ./ -name '*.html.py' -delete;
find ./ -name '*.txt.py' -delete;
echo "Done"
}
function sudo_clean() {
sudo find ./ -name '*.pyc' -exec rm -rf {} \;
sudo find ./ -name '__pycache__' -print0 | xargs -0 rm -rf;
sudo rm -rf ./xunit* ./.coverage* ./.pytest_cache ./*artifacts.tar.gz;
sudo truncate -s0 log/voipgrid*.log
sudo find ./ -name '*.py.py' -delete;
sudo find ./ -name '*.html.py' -delete;
sudo find ./ -name '*.txt.py' -delete;
echo "Done"
}
# Process changes in *.in files.
function pipcompile() {
pip-compile --no-annotate -r requirements.in
pip-compile --no-annotate -r requirements-dev.in
pip-compile --no-annotate -r requirements-staging.in
}
# Sync local env with requirements txt files.
function pipsync() {
pip-sync requirements.txt requirements-dev.txt
./contrib/patch_packages.py --apply
}
# new minor or hotfix tag
tag() {
# update everything including tags.
git fetch --tags
# get tag for current HEAD
current_tag_full=$(git describe --tag)
# get jus the tag, strip the number of commits ahead and short commit hash
current_tag=$(cut -d '-' -f 1 <<< "$current_tag_full")
if [[ $# -eq 0 ]]
then
echo "$current_tag"
else
# strip prefix 'v'
current_version=${current_tag:1}
# break it up into $numbers. Don't use an array, because they
# are not interchangeable with zsh.
major=$(echo "$current_version" | cut -d. -f1)
minor=$(echo "$current_version" | cut -d. -f2)
patch=$(echo "$current_version" | cut -d. -f3)
# tag up -> from 2.18.2 to 2.19.0
if [[ "$1" == "up" ]]
then
new_tag="v$major.$((minor+1)).0"
# tag hotfix -> from 2.18.2 to 2.18.3
elif [[ "$1" == "hotfix" ]]
then
new_tag="v$major.$minor.$((patch+1))"
fi
echo "git tag -a $new_tag -m '$new_tag'"
echo "git push origin $new_tag"
fi
}
# remove traces of branches that were removed.
function ggone() {
git fetch -p
git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D
}
# Loop given tests until it fails.
function rununtilfail() {
set -x
echo "Start testrun until failure '$@'"
while [ "$?" ];
do
pytest "$@";
done
set +x
}
# Remove given branch(es) local and remote.
function gdelete(){
while [[ $# -gt 0 ]]
do
key="$1"
echo "Deleting git branch '$key'"
git push origin --delete --no-verify $key
git branch -D $key
shift # past argument
done
}
# Start screen to manage vpn in.
function start_vpn() {
screen -t "start_vpn" bash -c "sudo openvpn --config /etc/openvpn/myvpn/myvpn.ovpn"
}
# Lazy man aliases.
alias doco=docker-compose
alias gs="git status"
alias gp="git pull -p"
alias gma="git commit --amend --no-edit"
alias gitmerge="git merge --no-ff"