meli/scripts/pre-commit

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.4 KiB
Plaintext
Raw Normal View History

2018-09-03 22:46:41 +00:00
#!/bin/bash
# SPDX-License-Identifier: EUPL-1.2
2018-09-03 22:46:41 +00:00
IFS=$'\n'
2018-09-03 22:46:41 +00:00
files_without_header=()
2018-09-03 22:46:41 +00:00
newly_added_files=($(git diff --name-only --diff-filter=A --cached))
#newly_added_files=($(git ls-files))
if [ -n "${newly_added_files[0]}" ]
2018-09-03 22:46:41 +00:00
then
# Check for Copyright statement
for newly_added_file in ${newly_added_files}; do
files_without_header+=($(grep -L -e "This file is part of meli" -e "This file is part of melib" -e "SPDX-License-Identifier" "${newly_added_file}"))
done
if [ -n "${files_without_header[0]}" ]
then
echo "License preamble not found in the following newly added files:"
for file in "${files_without_header[@]}"
do
:
echo " - ${file}";
done
exit 1;
else
exit 0;
fi
##Debug:
#files_without_header+=($(git diff --name-only -S"debug!"))
#echo ${files_without_header}
#if [ -n "${files_without_header}" ]
#then
# (echo "debug! macro added in the following files:";
# echo "";
# for file in "${files_without_header[@]}"
# do
# :
# tput bold
# echo " - ${file}";
# echo "";
# tput sgr0;
# FORCE_COLOR=true git -c color.status=always diff --color=always -S"debug!" "${file}";
# done) | less -R
# exit 1;
#else
# exit 0;
#fi
2018-09-03 22:46:41 +00:00
fi