Skip to content

Instantly share code, notes, and snippets.

@zmughal
Last active December 26, 2017 18:27
Show Gist options
  • Save zmughal/8701dda0c421b031169336fd0b438951 to your computer and use it in GitHub Desktop.
Save zmughal/8701dda0c421b031169336fd0b438951 to your computer and use it in GitHub Desktop.
# vim: ft=gitconfig
[alias]
branch-name = rev-parse --abbrev-ref HEAD
last-tag = describe --tags --abbrev=0
log-commits-since-last-tag = "! f() { git log `git last-tag`..HEAD $@; }; f"
log-commits-since-last-tag-oneline = !git log-commits-since-last-tag --oneline
last-tag-dotdot-or-nothing = "! f() { git last-tag >/dev/null 2>&1 && echo $(git last-tag).. || echo ''; }; f"
last-tag-or-root = "! f() { git last-tag >/dev/null 2>&1 && echo tag $(git last-tag) || echo 'ROOT'; }; f"
date-of-last-commit-on-head = ! git rev-list --format=%ci HEAD^! | tail -1
count-commits-since-last-tag-or-root = "! f() { git rev-list $(git last-tag-dotdot-or-nothing)HEAD --count; }; f"
branch-unmerged-count = "! f() { git branch --no-merged HEAD | wc -l; }; f"
release-state-col-headers = "! echo 'path,branch,commits since tag,last commit date,unmerged branches,# of releases'"
release-state-valid = "! f() { echo $(basename $(pwd)),$(git branch-name),$(git count-commits-since-last-tag-or-root) commits since $(git last-tag-or-root),$(git date-of-last-commit-on-head),$(git branch-unmerged-count) 'branch(es)' unmerged,$(git tag -l|wc -l) 'release(s)'; }; f"
release-state-invalid = "! f() { echo $(basename $(pwd )),,,,,No releases; }; f"
release-state = "! f() { ( git status -bs | grep -q 'No commits yet' && git release-state-invalid) || (git release-state-valid); }; f"
#!/bin/bash
# cpanm App::got App::GitGot
if [ -n "$1" ]; then
RE="$1"
else
RE='since tag v[0-9.]\+'
fi
(git release-state-col-headers; gott do -t renard,cpan -e 'git release-state' 2>/dev/null \
| got-filter \
| grep "$RE" \
| sort -t, -k3n -k5n -k4d \
| tac ) \
| csv2asciitable \
| perl -E '
my $head_last;
while(<<>>) {
next if $. == 2; # skip line 2
# swap line 3 and 4 (column rule and column names)
if( $. == 3 ){ $head_last = $_; next }
if( $. == 4 ) { print "$_$head_last"; next }
print
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment