forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-stats
More file actions
executable file
·45 lines (38 loc) · 1.05 KB
/
git-stats
File metadata and controls
executable file
·45 lines (38 loc) · 1.05 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
#!/usr/bin/env bash
# This script outputs statistics for the current git repository. This script
# is used by the search-core team to understand the size and shape of a
# repository. In particular we use this when understanding the scale of a
# monorepo to help us guide our work.
set -e
# Do everything from the gitdir. Makes ls-tree below also not work on a
# subtree.
cd "$(git rev-parse --git-dir)"
# The size of the git store (not the working copy).
echo "$(du -sh .)" gitdir
# The number of commits reachable from HEAD
echo "$(git rev-list --count HEAD)" commits
# Some awk which extracts statistics on the files in the latest commit.
echo
echo HEAD statistics
git ls-tree -r --long HEAD | awk '
BEGIN {
base = 10
logbase = log(base)
}
$4 != "-" {
if ($4 == 0) {
hist[0]++
} else {
hist[int(log($4) / logbase) + 1]++
}
total += $4
count++
}
END {
printf("%.3fGiB\n%d files\n", total / 1024 / 1024 / 1024, count)
printf("histogram:\n")
for (x in hist) {
printf("%d^%d\t%d\n", base, x, hist[x])
}
}
'