aboutsummaryrefslogtreecommitdiffstats
path: root/tools/status
blob: f053ef49f673e27a7a24d504c4b09507435278d3 (plain)
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
#!/usr/bin/env bash


y=$(basename $(pwd))
b=$(git branch | grep '\*' | tr '*' ' ')

# Control

all=
year=true

case $1 in
    -v) all=true ;;
esac

if ! [[ $y =~ ^[0-9]*$ ]]; then # Not a year
    year=
    all=true
fi


function year_branches {
    echo "Minues tex files $y on $b:"
    ls -1 $y*.tex | while read f; do
        wc=$(cat $f | sed '/begin{document}/,/end{document}/ p; d' | wc -w)
        echo "  $(printf '%s %4.d' $f $wc)"
    done

    echo "Local branches of $y:"
    git branch | grep "master\|$y" | tr '*' ' ' \
        | xargs -I{} -n1 git log -n1 \
                --pretty=format:"  {} - %h -%d%n      %s%n      (%an, %ad, %cr)"\
                {}
}

function all_branches {
    echo "All branches (commiter date, author date, hash, branch):"
    git branch -a | tr '*' ' ' | grep -v HEAD \
        | xargs -n1 git log -n1 \
                --date=short \
                --pretty=format:'  %cd %ad %h -%d%n' \
        | sort -u
}

if [[ "${0##*/}" == "status" ]]; then
    test -n "$year" && year_branches
    test -n "$all" && all_branches
fi