diff --git a/.githooks/pre-push b/.githooks/pre-push new file mode 100755 index 0000000000..bd69fff542 --- /dev/null +++ b/.githooks/pre-push @@ -0,0 +1,17 @@ +#!/bin/bash + +protected_branch='master' +current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') + +if [ $protected_branch = $current_branch ] +then + read -p "You're about to push to '$protected_branch', is that what you intended? [y|n] " -n 1 -r < /dev/tty + echo + if echo $REPLY | grep -E '^[Yy]$' > /dev/null + then + exit 0 + fi + exit 1 +else + exit 0 +fi diff --git a/docs/changelog.rst b/docs/changelog.rst index e7232d1654..37b1131b53 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -28,6 +28,7 @@ CHANGELOG **Maintenance** +- Add a git hook to prevent pushing to master. - Update to paperclip 2.5.0 diff --git a/docs/contribute/development.rst b/docs/contribute/development.rst index e7de37470b..9c6ecf2d7d 100644 --- a/docs/contribute/development.rst +++ b/docs/contribute/development.rst @@ -31,7 +31,7 @@ Conventions * KISS & DRY as much as possible * Elegant and generic is good, simple is better * Commits messages are explicit and mention issue number (``(ref #12)`` or ``(fixes #23)``) -* Features are developed in a branch and merged from Github pull-requests. +* Features are developed in a branch and merged from Github pull-requests. A git hook to is available to prevent pushing to master, to enable it, developpers should run the following command from root directory (`Geotrek-admin/`) : `ln -s -f ../../.githooks/pre-push .git/hooks/pre-push` Definition of done