-
Notifications
You must be signed in to change notification settings - Fork 0
/
.githelpers
70 lines (55 loc) · 2.08 KB
/
.githelpers
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
#!/bin/bash
LOG_HASH="%C(always,yellow)%h%C(always,reset)"
LOG_RELATIVE_TIME="%C(always,green)(%ar)%C(always,reset)"
LOG_AUTHOR="%C(always,blue)<%an>%C(always,reset)"
LOG_SUBJECT="%s"
LOG_REFS="%C(always,red)%d%C(always,reset)"
LOG_FORMAT="$LOG_HASH}$LOG_RELATIVE_TIME}$LOG_AUTHOR}$LOG_REFS $LOG_SUBJECT"
BRANCH_PREFIX="%(HEAD)"
BRANCH_REF="%(color:red)%(color:bold)%(refname:short)%(color:reset)"
BRANCH_HASH="%(color:yellow)%(objectname:short)%(color:reset)"
BRANCH_DATE="%(color:green)(%(committerdate:relative))%(color:reset)"
BRANCH_AUTHOR="%(color:blue)%(color:bold)<%(authorname)>%(color:reset)"
BRANCH_CONTENTS="%(contents:subject)"
BRANCH_FORMAT="$BRANCH_PREFIX}$BRANCH_REF}$BRANCH_HASH}$BRANCH_DATE}$BRANCH_AUTHOR}$BRANCH_CONTENTS"
pretty_git_log_ignores() {
git log -n 5000 --invert-grep --grep="\[skip ci\]" --graph --pretty="tformat:${LOG_FORMAT}" $* | pretty_git_format | git_page_maybe
}
pretty_git_log_all() {
git log -n 5000 --graph --pretty="tformat:${LOG_FORMAT}" $* | pretty_git_format | git_page_maybe
}
pretty_git_log_me() {
git log -n 5000 --author=waldner --graph --pretty="tformat:${LOG_FORMAT}" $* | pretty_git_format | git_page_maybe
}
pretty_git_format() {
# Replace (2 years ago) with (2 years)
sed -Ee 's/(^[^<]*) ago\)/\1)/' |
# Replace (2 years, 5 months) with (2 years)
sed -Ee 's/(^[^<]*), [[:digit:]]+ .*months?\)/\1)/' |
# Line columns up based on } delimiter
column -s '}' -t
}
git_page_maybe() {
# Page only if we're asked to.
if [ -n "$GIT_NO_PAGER" ]; then
cat
else
# Page only if needed.
less --quit-if-one-screen --no-init --RAW-CONTROL-CHARS --chop-long-lines
fi
}
# Go to main, pull and fetch
main() {
git checkout main && git pull && git fetch -p
}
# Go to master, pull and fetch
master() {
git checkout master && git pull && git fetch -p
}
# Clean all branches except main|master and the current branch I'm on
clean_branches() {
git checkout main && git branch | egrep -v "(main|master|\*)" | xargs git branch -D
}
emptycommit() {
git commit --allow-empty-message -m ""
}