2019-05-17 19:14:20 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
COPYRIGHT="COPYRIGHT.txt"
|
|
|
|
CONTRIBUTOR_NAMES="/tmp/repository-CONTRIBUTOR-NAMES.txt"
|
|
|
|
CONTRIBUTORS="/tmp/repository-CONTRIBUTORS.txt"
|
|
|
|
|
|
|
|
FILTERS="jenkins-jobs/scripts/config/FilteredNames.txt"
|
2021-03-19 11:57:12 +01:00
|
|
|
FILTERED_COMMITS="jenkins-jobs/scripts/config/FilteredCommits.txt"
|
2019-05-17 19:14:20 +02:00
|
|
|
ALIASES="jenkins-jobs/scripts/config/Aliases.txt"
|
|
|
|
|
2021-03-16 14:30:16 +01:00
|
|
|
declare -a DEBEZIUM_REPOS
|
|
|
|
if [ $# -eq 0 ];then
|
2023-10-26 10:19:00 +02:00
|
|
|
DEBEZIUM_REPOS=("debezium" "debezium-connector-db2" "debezium-connector-cassandra" "debezium-connector-vitess" "debezium-connector-spanner" "debezium-connector-jdbc" "debezium-connector-informix" "container-images" "debezium-server")
|
2021-03-16 14:30:16 +01:00
|
|
|
else
|
|
|
|
DEBEZIUM_REPOS=( "$@" )
|
|
|
|
fi
|
2019-05-17 19:14:20 +02:00
|
|
|
|
|
|
|
rc=0
|
2021-03-16 14:30:16 +01:00
|
|
|
|
|
|
|
for REPO in "${DEBEZIUM_REPOS[@]}";
|
2019-05-17 19:14:20 +02:00
|
|
|
do
|
2021-03-16 14:30:16 +01:00
|
|
|
git --git-dir=../"$REPO"/.git log --pretty=format:"%an" . | sort | uniq > $CONTRIBUTOR_NAMES
|
|
|
|
git --git-dir=../"$REPO"/.git log --pretty=format:"%an|%ae" . | sort | uniq > $CONTRIBUTORS
|
|
|
|
|
|
|
|
while read LINE
|
|
|
|
do
|
|
|
|
# First check whether the contributor name from git history is in the COPYRIGHT file.
|
|
|
|
# If the name exists, there is nothing else to do but if it does not we proceed with other checks.
|
|
|
|
if ! grep -qi "$LINE" $COPYRIGHT; then
|
2019-05-17 19:14:20 +02:00
|
|
|
|
|
|
|
# Check if the supplied contributor name from git history should be filtered
|
|
|
|
# This is where we want users like "Jenkins user" to be ignored.
|
|
|
|
# For users that should be skipped entirely, add them to config/FilteredNames.txt
|
|
|
|
if ! grep -qi "^$LINE$" $FILTERS; then
|
|
|
|
|
|
|
|
# Check the alias file and transform the git user to an alias if one is defined.
|
|
|
|
# If no alias is defined, NAME will be empty.
|
|
|
|
NAME=`grep -i "^$LINE," $ALIASES | head -1 | awk '{split($0,a,","); print a[2]}'`
|
2019-05-20 15:49:52 +02:00
|
|
|
EMAIL=`grep -i "^$LINE|" $CONTRIBUTORS | head -1 | awk '{split($0,a,"|"); print a[2]}'`
|
2019-05-17 19:14:20 +02:00
|
|
|
|
|
|
|
# Test if the history username was an alias.
|
|
|
|
# If it was not a defined alias, write that to the log and return 1
|
|
|
|
# If it did resolve as an alias, use the resolved name to see if its in the COPYRIGHT file
|
|
|
|
# and return 1 only if the resolved name was not already listed.
|
|
|
|
if test -z "$NAME"; then
|
2021-03-19 11:57:12 +01:00
|
|
|
COMMIT=`git --git-dir=../"$REPO"/.git log --pretty=format:"%H" --author "$LINE" | head -1`
|
|
|
|
if ! grep -qi "$COMMIT" "$FILTERED_COMMITS"; then
|
2021-03-19 13:47:56 +01:00
|
|
|
echo "Commit $COMMIT in $REPO: Did not find [$LINE] with email [$EMAIL]."
|
2019-05-17 19:14:20 +02:00
|
|
|
rc=1
|
2021-03-19 11:57:12 +01:00
|
|
|
fi
|
2019-05-17 19:14:20 +02:00
|
|
|
else
|
|
|
|
if ! grep -qi "$NAME" $COPYRIGHT; then
|
|
|
|
echo "Found [$LINE] (translated to [$NAME]) but the name wasn't in the COPYRIGHT.txt file."
|
|
|
|
rc=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2021-03-16 14:30:16 +01:00
|
|
|
fi
|
|
|
|
done < "$CONTRIBUTOR_NAMES"
|
|
|
|
done
|
2019-05-17 19:14:20 +02:00
|
|
|
|
2021-03-16 14:30:16 +01:00
|
|
|
exit $rc;
|