diff options
author | Etienne Champetier <champetier.etienne@gmail.com> | 2017-07-23 12:51:59 -0700 |
---|---|---|
committer | Etienne Champetier <champetier.etienne@gmail.com> | 2017-07-24 11:04:30 -0700 |
commit | 78712dfca8c54577306ef7935d08eb1862153265 (patch) | |
tree | 9ef7f0ce77f8c0971fd71c105209b3e4661a3b21 | |
parent | 2ce9c3a64af146b0c09538888c02a340f08224d0 (diff) |
build,travis: test commits format
Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
-rw-r--r-- | .travis.yml | 1 | ||||
-rwxr-xr-x | .travis_do.sh | 38 |
2 files changed, 39 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml index e8e37aa7d..ee321b375 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,4 +11,5 @@ before_script: - ./.travis_do.sh download_sdk script: + - ./.travis_do.sh test_commits - ./.travis_do.sh test_packages diff --git a/.travis_do.sh b/.travis_do.sh index d27ebbfd3..673dced26 100755 --- a/.travis_do.sh +++ b/.travis_do.sh @@ -104,6 +104,44 @@ EOF exit $RET } +test_commits() { + RET=0 + for commit in $(git rev-list ${TRAVIS_COMMIT_RANGE/.../..}); do + echo_blue "=== Checking commit '$commit'" + if git show --format='%P' -s $commit | grep -qF ' '; then + echo_red "Pull request should not include merge commits" + RET=1 + fi + + author="$(git show -s --format=%aN $commit)" + if echo $author | grep -q '\S\+\s\+\S\+'; then + echo_green "Author name ($author) seems ok" + else + echo_red "Author name ($author) need to be your real name 'firstname lastname'" + RET=1 + fi + + subject="$(git show -s --format=%s $commit)" + if echo "$subject" | grep -q '^[0-9A-Za-z,]\+: '; then + echo_green "Commit subject line seems ok ($subject)" + else + echo_red "Commit subject line MUST start with '<package name>: ' ($subject)" + RET=1 + fi + + body="$(git show -s --format=%b $commit)" + sob="$(git show -s --format='Signed-off-by: %aN <%aE>' $commit)" + if echo "$body" | grep -qF "$sob"; then + echo_green "Signed-off-by match author" + else + echo_red "Signed-off-by is missing or doesn't match author (should be '$sob')" + RET=1 + fi + done + + exit $RET +} + echo_blue "=== Travis ENV" env echo_blue "=== Travis ENV" |