Created
October 14, 2015 14:52
-
-
Save s4parke/84e834e028f027b90028 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby | |
# Git before-update hook | |
def check_uncommitted_changes | |
diff_paths = `git diff-index --name-only HEAD`.split("\n") | |
diff_stats = `git diff-index --stat HEAD`.split("\n").join("\n ") | |
error_msg = %( | |
[GIT POLICY: DIRTY WORKING COPY] | |
There are uncommitted changes in server's working copy. Please commit or stash them. | |
#{diff_stats} | |
) | |
puts error_msg | |
unless diff_paths.nil? || diff_paths.empty? | |
puts error_msg | |
exit 1 | |
end | |
end | |
check_uncommitted_changes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment