Last active
          February 1, 2017 11:55 
        
      - 
      
- 
        Save davidhavard/cef9878ede56fd219c46c545e82ec809 to your computer and use it in GitHub Desktop. 
    Basic git hook to check for Jira issue number in commit message
  
        
  
    
      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
    
  
  
    
  | #!/bin/bash | |
| # | |
| # Create commit hook for all git repos | |
| # to check for JIRA ticket number in | |
| # commit message | |
| # | |
| # INSTALL: | |
| # | |
| # sh -c "$(curl -fsSL https://gist.github.com/davidhavard/cef9878ede56fd219c46c545e82ec809/raw/gistfile1.txt)" | |
| # | |
| # | |
| # Create hooks in all git repos | |
| # | |
| find . -type d -name '.git' | while read PROJECT; do | |
| PATH=$PROJECT/hooks/commit-msg | |
| echo "Creating commit hook '$PATH'" | |
| echo "#!/bin/sh" > $PATH | |
| echo "test \"\" != \"\$(grep -E '[A-Z|0-9]{2,9}-[0-9]+' \"\$1\")\" || {" >> $PATH | |
| echo " echo -e >&2 \"\e[31mERROR: Looks like you forgot the issue number.\e[0m\"" >> $PATH | |
| echo " exit 1" >> $PATH | |
| echo "}" >> $PATH | |
| /bin/chmod +x $PATH | |
| done | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment