File: kernel-stats.sh

package info (click to toggle)
kworkflow 20191112-1.2
  • links: PTS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,836 kB
  • sloc: perl: 7,354; sh: 2,397; ansic: 80; python: 44; makefile: 38
file content (225 lines) | stat: -rwxr-xr-x 6,825 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/bin/bash

# TODO:
# - issue when there 2 signed-off-by from the same company
# - SOB count should ignore authors
#

AUTHOR="collabora"

FORMAT="<li><a href=\"https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=%H\">%s</a></li>"

SUBDIRS="arch block crypto  Documentation drivers firmware fs include init ipc  kernel  lib  mm net  samples scripts security sound tools usr  virt"

DRMDIRS="amd arc arm armada ast bochs bridge cirrus drm_*.c etnaviv exynos fsl-dcu gma500 hisilicon i2c i810 i915 imx lib mediatek meson mga mgag200 msm mxsfb nouveau omapdrm panel pl111 qxl r128 radeon rcar-du rockchip savage scheduler selftests shmobile sis sti stm sun4i tdfx tegra tilcdc tinydrm ttm tve200 udl vc4 vgem via virtio vmwgfx zte"

DRVDIRS="accessibility acpi amba android ata atm auxdisplay base bcma block bluetooth bus cdrom char clk clocksource connector cpufreq cpuidle crypto dax dca devfreq dio dma dma-buf edac eisa extcon firewire firmware fmc fpga fsi gpio gpu hid hsi hv hwmon hwspinlock hwtracing i2c ide idle iio infiniband input iommu ipack irqchip isdn leds lightnvm macintosh mailbox mcb md media memory memstick message mfd misc mmc mtd mux net nfc ntb nubus nvdimm nvme nvmem of opp oprofile parisc parport pci pcmcia perf phy pinctrl platform pnp power powercap pps ps3 ptp pwm rapidio ras regulator remoteproc reset rpmsg rtc s390 sbus scsi sfi sh siox slimbus sn soc soundwire spi spmi ssb staging target tc tee thermal thunderbolt tty uio usb uwb vfio vhost video virt virtio visorbus vlynq vme w1 watchdog xen zorro"

ARMDIRS="boot common configs crypto firmware include kernel kvm lib mach-actions mach-alpine mach-artpec mach-asm9260 mach-aspeed mach-at91 mach-axxia mach-bcm mach-berlin mach-clps711x mach-cns3xxx mach-davinci mach-digicolor mach-dove mach-ebsa110 mach-efm32 mach-ep93xx mach-exynos mach-footbridge mach-gemini mach-highbank mach-hisi mach-imx mach-integrator mach-iop13xx mach-iop32x mach-iop33x mach-ixp4xx mach-keystone mach-ks8695 mach-lpc18xx mach-lpc32xx mach-mediatek mach-meson mach-mmp mach-moxart mach-mv78xx0 mach-mvebu mach-mxs mach-netx mach-nomadik mach-nspire mach-omap1 mach-omap2 mach-orion5x mach-oxnas mach-picoxcell mach-prima2 mach-pxa mach-qcom mach-realview mach-rockchip mach-rpc mach-s3c24xx mach-s3c64xx mach-s5pv210 mach-sa1100 mach-shmobile mach-socfpga mach-spear mach-sti mach-stm32 mach-sunxi mach-tango mach-tegra mach-u300 mach-uniphier mach-ux500 mach-versatile mach-vexpress mach-vt8500 mach-w90x900 mach-zx mach-zynq mm net nwfpe oprofile plat-iop plat-omap plat-orion plat-pxa plat-samsung plat-versatile probes tools vdso vfp xen"

ARM64DIRS="boot configs crypto include kernel kvm lib mm net xen"

function sum_commits {
	s=$(sed -e  "s/^ *\([0-9]\+\).*/+ \1/g" | tr -d '\n' | cut -c 2-)
	if [ "$s" == "" ] ; then
		echo 0
	else
		echo "$s" | bc
	fi
}

function get_names {
	COMMITS=$(git log --grep="$2.*$AUTHOR" --format=%H $1)
	NAMES=""
	for c in $COMMITS ; do
		NAME=$(git show $c | grep "$2.*$AUTHOR" | sed -e "s/^[ ]\+$2: \(.*\) <[a-z\.]*@[a-z\.]*>.*$/\1/g" | tr -d "\n")
		if [ "$2" = "Signed-off-by" ] ; then
			if git show $c | grep -q "Author: $NAME.*" ; then
				NAME=""
			fi
		fi

		if [ "$NAME" != "" ] ; then
			NAME="$NAME\n"
		fi

		NAMES+=$NAME
	done

	echo -e $NAMES | sort | uniq | grep "[A-Z]"
}

function find_commits {

	get_names $1 $2 | while read NAME ; do
		if [ "$NAME" = "" ] ; then
			continue
		fi

		COMMITS=$(git log --grep="$2: $NAME .*$AUTHOR" --format=%H $1)
		echo -n "$NAME ("
		git log --grep="$2: $NAME .*$AUTHOR" --format=%H $1 | wc -l | tr -d "\n"
		echo "):"
		
		for c in $COMMITS ; do
			git show --no-patch --format="$FORMAT" $c | cat
		done

		echo ""
	done
}

function find_commits_sob {

	get_names $1 $2 | while read NAME ; do
		if [ "$NAME" = "" ] ; then
			continue
		fi

		COMMITS=$(git log --perl-regexp --author="^((?!$NAME).*)$" \
			--grep "Signed-off-by: $NAME.*" --format=%H $1)
		echo -n "$NAME ("
		git log --perl-regexp --author="^((?!$NAME).*)$" \
			--grep "Signed-off-by: $NAME.*" --format=%H $1 | wc -l | tr -d "\n"
		echo "):"

		for c in $COMMITS ; do
			git show --no-patch --format="$FORMAT" $c | cat
		done

		echo ""
	done
}

function ks_report {
	echo "=== Authors summary ==="
	git shortlog -ns $1  --author=$AUTHOR | cat
	echo ""

	echo "=== Authors total commits ==="
	git shortlog -ns $1  --author=$AUTHOR | sum_commits
	echo ""

	echo "=== Reviewed-by names ==="
	get_names $1 "Reviewed-by"
	echo ""

	echo "=== Reviewed-by total tags ==="
	git log --grep="Reviewed-by.*$AUTHOR" --oneline $1 | wc -l
	echo ""

	echo "=== Signed-off-by names ==="
	get_names $1 "Signed-off-by"
	echo ""

	echo "=== Signed-off-by total tags ==="
	git log --grep="Signed-off-by.*$AUTHOR" --oneline $1 | wc -l
	echo ""

	echo "=== Tested-by names ==="
	get_names $1 "Tested-by"
	echo ""

	echo "=== Tested-by total tags ==="
	git log --grep="Tested-by.*$AUTHOR" --oneline $1 | wc -l
	echo ""

	echo "=== Suggested-by names ==="
	get_names $1 "Suggested-by"
	echo ""

	echo "=== Suggested-by total tags ==="
	git log --grep="Suggested-by.*$AUTHOR" --oneline $1 | wc -l
	echo ""

	echo " === HTML report ==="
	echo ""

	echo "<h4>Here is the complete list of Collabora contributions:</h4>"
	git shortlog $1  --author=$AUTHOR --format="$FORMAT" | cat
	echo ""

	echo "<br />"
	echo "<h4>Reviewed-by:</h4>"
	find_commits $1 "Reviewed-by"
	echo ""

	echo "<br />"
	echo "<h4>Signed-off-by:</h4>"
	find_commits_sob $1 "Signed-off-by"
	echo ""

	echo "<br />"
	echo "<h4>Tested-by:</h4>"
	find_commits $1 "Tested-by"
	echo ""

	echo "<br />"
	echo "<h4>Suggested-by:</h4>"
	find_commits $1 "Suggested-by"
	echo ""
}

function per_year {
	YEAR=$(date +%Y)
	for i in $(seq 13) ; do
		git shortlog -ns \
			--after=31,Dec,$(expr $YEAR - 1) \
			--before=1,Jan,$(expr $YEAR + 1) --author=$1 | sum_commits
		let YEAR--
	done
}

function for_each_dir {
	local RANGE="$1"
	local AUTHOR="$2"
	local DIRS="$3"
	local PREFIX="$4"

	for d in $DIRS ; do
		num=$(git shortlog -ns "$RANGE" --author="$AUTHOR" -- $PREFIX$d | sum_commits)
		if [ $num -ge 10 ] ; then 
			echo "$PREFIX$d;$num"
		fi
	done
}

function per_dir {
	echo "** $2 **"
	echo "total: $(git shortlog -ns --author=$2 "$1" | sum_commits)"
	echo " == subdirs: =="
	for_each_dir "$1" "$2" "$SUBDIRS" ""
	echo "== drivers/ =="
	for_each_dir "$1" "$2" "$DRVDIRS" "drivers/"
	echo "== drivers/gpu/drm/ =="
	for_each_dir "$1" "$2" "$DRMDIRS" "drivers/gpu/drm/"
	echo "== arch/arm/ =="
	for_each_dir "$1" "$2" "$ARMDIRS" "arch/arm/"
	echo "== arch/arm64/ =="
	for_each_dir "$1" "$2" "$ARM64DIRS" "arch/arm64/"
	echo ""
}

function help {
i	echo "no help yet"
}

case "$1" in
	report)
		ks_report "$2"
		;;
	yearly)
		per_year "$2"
		;;
	dir)
		per_dir "$2" "$3"
		;;
	help)
		ks_help
		;;
	*)
		ks_help
		exit 1
esac

exit 0