Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jarentaq/a8483a1efd9ee39bb5eb3e9f8385a921 to your computer and use it in GitHub Desktop.

Select an option

Save jarentaq/a8483a1efd9ee39bb5eb3e9f8385a921 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
git log --date=format:%Y --format='%ad %aN <%ae>' | sort | uniq | awk '
BEGIN {
NAUTHORS=0
MIN_YEAR=2025
USE_DASH=0
MAP["Andrew Zonenberg <azonenberg@drawersteak.com>"] = "Andrew D. Zonenberg <azonenberg@drawersteak.com>"
MAP["bvernoux <bvernoux@gmail.com>"] = "Benjamin Vernoux <bvernoux@gmail.com>"
}
{
YEAR=$1;
if (YEAR < MIN_YEAR) {
MIN_YEAR=YEAR
};
$1="";
AUTHOR=substr($0,2);
if (MAP[AUTHOR]) {
AUTHOR=MAP[AUTHOR];
}
if (!ALL_AUTHORS[AUTHOR]) {
AUTHORS[NAUTHORS]=AUTHOR;
NAUTHORS=NAUTHORS+1;
ALL_AUTHORS[AUTHOR]=1
}
AUTHOR_YEAR[AUTHOR"_"YEAR] = 1
}
END {
for (i=0;i<NAUTHORS;i++) {
LAST_YEAR=0;
WITH_DASH=0;
for (y=MIN_YEAR;y<=2025;y++) {
if (AUTHOR_YEAR[AUTHORS[i]"_"y]) {
if (LAST_YEAR) {
if (USE_DASH && LAST_YEAR + 1 == y) {
WITH_DASH=1;
} else {
if (WITH_DASH) {
printf("-%d,%d", LAST_YEAR, y);
} else {
printf(",%d", y);
}
WITH_DASH=0;
}
} else {
printf("%d", y);
}
LAST_YEAR=y;
}
}
if (WITH_DASH) {
printf("-%d", LAST_YEAR);
}
printf(" %s\n", AUTHORS[i]);
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment