#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: $0 <starting_tag>"
echo "Example: $0 fuse-3.16.2"
exit 1
fi
START_TAG=$1
git_emails=$(git log ${START_TAG}..HEAD --format='<%aE>' | sort -u | sed 's/^<//;s/>$//')
authors_emails=$(grep -oP '(?<=<)[^>]+' AUTHORS | sort -u)
new_emails=$(comm -1 -3 <(echo "$authors_emails") <(echo "$git_emails"))
if [ -n "$new_emails" ]; then
echo -e "\nNew authors to be added:"
echo -e "\n# New authors since ${START_TAG}" >> AUTHORS
for email in $new_emails; do
author=$(git log -1 --format='%aN <%aE>' --author="$email")
echo "$author"
echo "$author" >> AUTHORS
done
echo "AUTHORS file has been updated."
else
echo "No new authors found since ${START_TAG}."
fi