Skip to content

Commit

Permalink
Merge pull request #3114 from GeotrekCE/git_hook
Browse files Browse the repository at this point in the history
Add git hook to prevent pushing to master
  • Loading branch information
submarcos authored May 25, 2022
2 parents 747dc80 + 7132b43 commit 5369642
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ CHANGELOG

**Maintenance**

- Add a git hook to prevent pushing to master.
- Update to paperclip 2.5.0


Expand Down
2 changes: 1 addition & 1 deletion docs/contribute/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5369642

Please sign in to comment.