Fix review issues
- Use git options to remove last commit from list to verify. - Check each line of a commit for a "Signed-off-by" line. - Exit with error in the event of no commits in PR! Signed-off-by: Fabio Utzig <utzig@apache.org>
This commit is contained in:
parent
5b989104a5
commit
311801775e
|
@ -15,14 +15,31 @@
|
||||||
MAIN_BRANCH=master
|
MAIN_BRANCH=master
|
||||||
|
|
||||||
# ignores last commit because travis/gh creates a merge commit
|
# ignores last commit because travis/gh creates a merge commit
|
||||||
commits=$(git log --format=%h ${MAIN_BRANCH}..HEAD | tail -n +2)
|
commits=$(git log --format=%h ${MAIN_BRANCH}..HEAD~1)
|
||||||
|
|
||||||
|
has_commits=false
|
||||||
for sha in $commits; do
|
for sha in $commits; do
|
||||||
actual=$(git show -s --format=%B ${sha} | sed '/^$/d' | tail -n 1)
|
|
||||||
expected="Signed-off-by: $(git show -s --format="%an <%ae>" ${sha})"
|
expected="Signed-off-by: $(git show -s --format="%an <%ae>" ${sha})"
|
||||||
|
lines="$(git show -s --format=%B ${sha})"
|
||||||
|
found_sob=false
|
||||||
|
IFS=$'\n'
|
||||||
|
for line in ${lines}; do
|
||||||
|
stripped=$(echo $line | sed -e 's/^\s*//' | sed -e 's/\s*$//')
|
||||||
|
if [[ $stripped == ${expected} ]]; then
|
||||||
|
found_sob=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
if [ "${actual}" != "${expected}" ]; then
|
if [[ ${found_sob} = false ]]; then
|
||||||
echo -e "${sha} is missing or using an invalid \"Signed-off-by:\" line"
|
echo -e "No \"${expected}\" found in commit ${sha}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
has_commits=true
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ ${has_commits} = false ]]; then
|
||||||
|
echo "No commits found in this PR!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in New Issue