-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgithelpers
More file actions
61 lines (51 loc) · 1.56 KB
/
githelpers
File metadata and controls
61 lines (51 loc) · 1.56 KB
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
#!/bin/bash
# Log output:
#
# * 238b2a (10 days) <Tim Uruski> did some work
#
# Stolen from Gary Bernhardt
# https://github.com/garybernhardt/dotfiles/blob/master/.githelpers
# https://www.destroyallsoftware.com/screencasts/catalog/pretty-git-logs
HASH="%C(yellow)%h%C(reset)"
RELATIVE_TIME="%C(green)(%ar)%C(reset)"
AUTHOR="%C(bold blue)<%an>%C(reset)"
REFS="%C(red)%d%C(reset)"
SUBJECT="%s"
FORMAT="$HASH}$RELATIVE_TIME}$AUTHOR}$REFS $SUBJECT"
show_git_head() {
pretty_git_log -1
git show -p --pretty="tformat:"
}
pretty_git_log() {
git log --graph --abbrev-commit --date=relative --pretty="tformat:${FORMAT}" $* |
# Replace (2 years ago) with (2 years)
sed -Ee 's/(^[^<]*) ago)/\1)/' |
# Replace (2 years, 5 months) wiht (2 years)
sed -Ee 's/(^[^>]*), [[:digit:]]+ .*months?)/\1)/' |
# Columnate based on } delimiter
column -s '}' -t |
# Page with colors, only when necessary, leave it on the screen
less -FSXR
}
deploy_git_log() {
ref=${1:-'master'}
date +"%d %b %Y"
git log --pretty="tformat: - %s [%an]" origin/$ref..$ref |
sed -Ee 's/\[([a-zA-Z]).+ ([a-zA-Z]).+\]$/[\1\2]/'
}
current_branch() {
# The --short was introduced in 1.7.9, this might be more portable.
# git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||'
# git symbolic-ref --short --quiet HEAD
git branch --show-current
}
ffwd() {
ref="${1:-origin}/$(current_branch)"
git merge --ff-only $ref
}
# push origin branch
push_origin() {
branch=${1:-$(current_branch)}
echo "git push origin ${branch}"
git push origin ${branch}
}