Re-enable blame (was annotate) with svn and git support.

ak@ asked that I remove the unused error array, and I went to have a
look at what it was actually used for back in the day.  It seemed better
to re-enable the blame feature instead of removing it.

Sponsored by:	Absolight
This commit is contained in:
Mathieu Arnold 2017-10-30 13:56:49 +00:00
parent e0d9bfd95b
commit 48fc012063
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=453175

View File

@ -38,6 +38,14 @@ BEGIN {
portsdir = ENVIRON["PORTSDIR"] ? ENVIRON["PORTSDIR"] : "/usr/ports"
if (ARGC == 1) {
ARGV[ARGC++] = portsdir "/MOVED"
if (ENVIRON["BLAME"]) {
if (!system("test -d " portsdir "/.svn")) {
blame = "cd " portsdir "; svn blame MOVED 2>/dev/null"
} else if (!system("test -d " portsdir "/.git")) {
blame = "cd " portsdir "; git blame MOVED 2>/dev/null"
}
}
}
sort = "/usr/bin/sort -n"
lastdate="1999-12-31"
@ -85,11 +93,15 @@ $3 !~ /^20[0-3][0-9]-[01][0-9]-[0-3][0-9]$/ {
}
# Produces too many false positives
# if ($4 ~ /^[a-z].*/)
# if ($4 ~ /^[a-z].*/) {
# printf "Initial value of 'reason' is lowercase: %5d (%s)\n", NR, $4 | sort
# error[NR] = 1
# }
if ($4 ~ /\.$/)
if ($4 ~ /\.$/) {
printf "%5d: Final character is a dot: (%s)\n", NR, $4 | sort
error[NR] = 1
}
}
END {
@ -103,5 +115,15 @@ END {
error[missing[port]] = 1
}
if (blame) {
line = 1
while (blame | getline) {
if (error[line])
printf "%5d!\n%5d! %s\n", line, line, $0 | sort
line++
}
close(blame)
}
close(sort)
}