File: git-summary

package info (click to toggle)
git-extras 1.7.0-1.2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 696 kB
  • sloc: sh: 381; makefile: 52
file content (77 lines) | stat: -rwxr-xr-x 1,088 bytes parent folder | download
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
#!/bin/bash

commit=""
test $# -ne 0 && commit=$@
project=${PWD##*/}

#
# get date for the given <commit>
#

date() {
  git log --pretty='format: %ai' $1 | cut -d ' ' -f 2
}

#
# get active days for the given <commit>
#

active_days() {
  date $1 | uniq | awk '
    { sum += 1 }
    END { print sum }
  '
}

#
# get the commit total
#

commit_count() {
  git log --oneline $commit | wc -l | tr -d ' '
}

#
# total file count
#

file_count() {
  git ls-files | wc -l | tr -d ' '
}

#
# list authors
#

authors() {
  git shortlog -n -s $commit | awk '
  { args[NR] = $0; sum += $0 }
  END {
    for (i = 1; i <= NR; ++i) {
      printf "%-30s %2.1f%%\n", args[i], 100 * args[i] / sum
    }
  }
  '
}

#
# fetch repository age from oldest commit
#

repository_age() {
  git log --reverse --pretty=oneline --format="%cr" | head -n 1
}

# summary

echo
echo " project  : $project"
echo " repo age :" $(repository_age)
echo " commits  :" $(commit_count)
echo " active   :"  $(active_days) days
if test "$commit" = ""; then
  echo " files    :" $(file_count)
fi
echo " authors  : "
authors
echo