blob: 3d5ae8771aa915eaa2e3e942de98eacee54d953c (
plain)
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
|
#!/bin/bash -e
#
# ninja-fix-MAINTAINERS - remove or replace bouncing email addresses from MAINTAINERS
# written by Wolfram Sang, (C) 2024 Sang Engineering
# free software - no warranty - WTFPL V2, see http://sam.zoy.org/wtfpl/
#
# Example: $ ninja-fix-MAINTAINERS "Wolfram Sang"
# will give you the list of email adresses used in the last 20 commits. Use the ugrep
# interface to select two if there is a newer one, or only one if all are old. Then,
# the email will be replaced or removed from MAINTAINERS, a commit will be created
# temporarily and a mail will be sent out.
remove=0
scan_maintainers=0
found_where="recent git history"
command -v ugrep > /dev/null || { echo "'ugrep' needs to be installed!"; exit 1; }
[ "$1" = "-m" ] && shift && scan_maintainers=1 && found_where="MAINTAINERS"
[ $# -lt 1 ] && echo "Author name missing" && exit 1
[ ! -r MAINTAINERS ] && echo "MAINTAINERS not found" && exit 1
cc_cmd='/dev/shm/ninja-cc-cmd'
if [ $scan_maintainers -eq 1 ]; then
readarray -t -n2 author < <(awk "/$*/ { \$1=\"\"; gsub(/^ /, \"\"); print }" MAINTAINERS | uniq | ugrep -Q)
else
readarray -t -n2 author < <(git log -n 20 --author="$*" --format='%aN <%aE>' | uniq | ugrep -Q)
fi
[ -z "${author[0]}" ] && exit 0
[ -z "${author[1]}" ] && remove=1
echo '#!/bin/sh' > $cc_cmd
chmod 755 $cc_cmd
gawk -i inplace -v remove=$remove "
remove && /${author[0]}/ { flag = 1; next }
!remove &&/${author[1]}/ { sub(\"${author[1]}\", \"${author[0]}\"); flag = 1 }
flag && /^L:/ { print \"echo \"\$2 >> \"$cc_cmd\" }
/^$/ { flag = 0 }
{ print }
" MAINTAINERS
git diff --quiet && exit 0
name="${author/ <*/}"
if [ $remove -eq 0 ]; then
git commit MAINTAINERS -s -F- <<-EOF
MAINTAINERS: update email for $name
The old email address bounced. I found the newer one in $found_where,
so update entries accordingly.
Cc: ${author[0]}
EOF
file="$(git format-patch -1 -o /dev/shm)"
sed -i "/^---\$/ { a \\\\nAgainst $(git describe HEAD^). Still needs ack from $name\\n
}" "$file"
else
git commit MAINTAINERS -s -F- <<-EOF
MAINTAINERS: delete email for $name
The email address bounced. I couldn't find a newer one in recent git history,
so delete this email entry.
EOF
file="$(git format-patch -1 -o /dev/shm)"
fi
git send-email --to lkml --cc-cmd="$cc_cmd" --annotate $file
rm $file $cc_cmd
git diff --quiet || { echo "Dirty tree! Not removing commit"; exit 1; }
git reset --hard HEAD^
|