Skip to content

Commit

Permalink
feat(validate-pr): Allow docs() commits to be merged in master
Browse files Browse the repository at this point in the history
I've added the possibility to push `docs()` commits when doing a PR to
master. Previously only messages containing the word `hotfix` could
pass the test. This should allow us more flexibility in fixing
documentation issues.

The public website is automatically build whenever a new commit lands
on master.

I've also refactored the file to follow linting advice from
`shellcheck` and make the three tests (hopefully) more readable.
  • Loading branch information
pixelastic committed Mar 7, 2016
1 parent 7a7982d commit 0abc689
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions scripts/validate-pr-done-on-develop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,26 @@

set -e # exit when error

COMMIT_MSG=`git log --format=%B --no-merges -n 1`
COMMIT_MSG=$(git log --format=%B --no-merges -n 1)
[[ "$COMMIT_MSG" =~ hotfix ]] && is_hotfix=1 || is_hotfix=0
[[ "$COMMIT_MSG" =~ /^docs/ ]] && is_doc=1 || is_doc=0
[[ "$TRAVIS_PULL_REQUEST" == false ]] && is_travis=1 || is_travis=0
[[ "$TRAVIS_BRANCH" == master ]] && is_master=1 || is_master=0
[[ "$TRAVIS_BRANCH" != develop ]] && is_develop=1 || is_develop=0

if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
MSG="No need to check pull request done on develop branch when not in a pull request"
EXIT=0
elif [[ "$COMMIT_MSG" =~ "hotfix" ]] && [ "$TRAVIS_BRANCH" == 'master' ]; then
MSG="Hotfix submitted to master, good"
EXIT=0
elif [ "$TRAVIS_BRANCH" != 'develop' ]; then
MSG="Pull request must be done on develop branch"
EXIT=1
if [[ $is_travis == 0 ]]; then
echo "No need to check pull request done on develop branch when not in a pull request"
exit 0
fi

echo $MSG;
exit $EXIT;
if [[ ($is_hotfix == 1 || $is_doc == 1) && $is_master == 1 ]]; then
echo "Hotfix submitted to master, good"
exit 0
fi

if [[ $is_develop == 0 ]]; then
echo "Pull request must be done on develop branch"
exit 1
fi

exit 0

0 comments on commit 0abc689

Please sign in to comment.