forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module_committers
executable file
·58 lines (47 loc) · 1.34 KB
/
module_committers
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
#!/bin/bash
set -euo pipefail
#
# Finds modules matching given string and prints out their recent top committers.
#
# Usage:
# module_devs <module name, partial ok>
#
find_beat_dirs() {
find $beats_base_dir -type d -iname \*beat -maxdepth 2 | grep -v libbeat
}
find_module_dirs() {
beat_dirs="$1"
module_name="$2"
module_dirs=""
for beat_dir in $beat_dirs; do
if [ -d "$beat_dir/module" ]; then
module_dirs=$module_dirs" "$(find $beat_dir/module -type d -depth 1)
fi
done
found_dirs=""
for module_dir in $module_dirs; do
module=$(echo $module_dir | awk -F\/ '{ print $NF}')
if [[ "$module" == *"$module_name"* ]]; then
found_dirs=$found_dirs" "$module_dir
fi
done
echo "$found_dirs"
}
print_recent_top_committers() {
module_dirs="$1"
for module_dir in $module_dirs; do
echo "Found matching $module_dir:"
cd $module_dir
echo " Recent top committers:"
git log --since="one year ago" --pretty=format:"%an" -- . | sort | uniq -c | sort -nr | head -3 | awk '{$1 = ""; print " -"$0}'
done
}
module_name="$1"
if [ -z "$module_name" ]; then
echo "Usage: module_devs <module name>"
exit 1
fi
beats_base_dir=$(cd $(dirname $BASH_SOURCE)/..; pwd)
beat_dirs=$(find_beat_dirs)
module_dirs=$(find_module_dirs "$beat_dirs" "$module_name")
print_recent_top_committers "$module_dirs"