-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcount-commits.sh
More file actions
executable file
·79 lines (63 loc) · 1.76 KB
/
count-commits.sh
File metadata and controls
executable file
·79 lines (63 loc) · 1.76 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# Script to count commits in each LLVM release and year.
# Copyright (C) 2025 Embecosm Limited
# Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
# SPDX-License-Identifier: GPL-3.0-or-later
set -u
usage () {
cat <<EOF
Usage ./count-commits.sh <name> <dirs>
EOF
}
if [[ $# -lt 2 ]]
then
usage
exit 1
fi
name=$1
shift
args="$*"
topdir="$(dirname $(cd $(dirname $0) && echo $PWD))"
llvmdir="${topdir}/llvm-project"
tooldir="${topdir}/toolchain-analyze"
# Need to work in the LLVM repo.
cd ${llvmdir}
# Create the list of current releases
rels="$(seq -s ' ' -f '1.%.0f' 1 9)"
rels="${rels} $(seq -s ' ' -f '2.%.0f' 0 9)"
rels="${rels} $(seq -s ' ' -f '3.%.0f' 0 9)"
rels="${rels} $(seq -s ' ' 4 20)"
# Create the list of years
years=$(seq 2001 2025)
# Commits per release
echo -n "Commits per release for ${name}"
resf="${tooldir}/commits-per-release.csv"
printf "%s,%s\n" "Release" "${name}" > ${resf}
# First release is special
num=$(git log --oneline --no-merges remotes/upstream/release/1.0.x ${args} | \
wc -l --total=only)
printf "%s,%d\n" "1.0" ${num} >> ${resf}
echo -n "."
# All the other releases
prev=1.0
for curr in ${rels}
do
num=$(git log --oneline --no-merges remotes/upstream/release/${curr}.x \
^remotes/upstream/release/${prev}.x ${args} | wc -l --total=only)
printf "%s,%d\n" "${curr}" ${num} >> ${resf}
echo -n "."
prev=${curr}
done
echo
# Commits per year
echo -n "Commits per year for ${name}"
resf="${tooldir}/commits-per-year.csv"
printf "%s,%s\n" "Year" "${name}" > ${resf}
for y in ${years}
do
num=$(git log --oneline --no-merges --since-as-filter="${y}-01-01" \
--until="${y}-12-31" ${args} | wc -l --total=only)
printf "%s-12-31,%d\n" "${y}" ${num} >> ${resf}
echo -n "."
done
echo