Skip to content

Instantly share code, notes, and snippets.

@logicaroma
Forked from pgilad/Instructions.md
Created November 1, 2015 20:20

Revisions

  1. @pgilad pgilad revised this gist Dec 1, 2014. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions commit-msg.sh
    Original file line number Diff line number Diff line change
    @@ -3,13 +3,14 @@
    # set this to your active development branch
    develop_branch="develop"
    current_branch="$(git rev-parse --abbrev-ref HEAD)"
    # regex to validate in commit msg
    commit_regex='(wap-[0-9]+|merge)'
    error_msg="Aborting commit. Your commit message is missing either a JIRA Issue ('WAP-1111') or 'Merge'"

    # only check commit messages on main development branch
    [ "$current_branch" != "$develop_branch" ] && exit 0

    # regex to validate in commit msg
    commit_regex='(wap-[0-9]+|merge)'
    error_msg="Aborting commit. Your commit message is missing either a JIRA Issue ('WAP-1111') or 'Merge'"

    if ! grep -iqE "$commit_regex" "$1"; then
    echo "$error_msg" >&2
    exit 1
  2. @pgilad pgilad revised this gist Oct 25, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion commit-msg.sh
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    develop_branch="develop"
    current_branch="$(git rev-parse --abbrev-ref HEAD)"
    # regex to validate in commit msg
    commit_regex='(wap-\d+|merge)'
    commit_regex='(wap-[0-9]+|merge)'
    error_msg="Aborting commit. Your commit message is missing either a JIRA Issue ('WAP-1111') or 'Merge'"

    # only check commit messages on main development branch
  3. @pgilad pgilad revised this gist Oct 23, 2014. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions Instructions.md
    Original file line number Diff line number Diff line change
    @@ -8,15 +8,15 @@

    ## Shell example

    ```sh
    $ curl https://gist.githubusercontent.com/pgilad/5d7e4db725a906bd7aa7/raw/feba0ca462f87a382cfbc3eddfcc529ceb9b7350/commit-msg > .git/hooks/commit-msg
    ```bash
    curl https://gist.githubusercontent.com/pgilad/5d7e4db725a906bd7aa7/raw/feba0ca462f87a382cfbc3eddfcc529ceb9b7350/commit-msg.sh > .git/hooks/commit-msg

    $ rm .git/hooks/commit-msg.sample
    rm .git/hooks/commit-msg.sample

    $ chmod +x .git/hooks/commit-msg
    chmod +x .git/hooks/commit-msg

    $ vim .git/hooks/commit-msg
    vim .git/hooks/commit-msg

    $ echo "Profit $$"
    echo "Profit $$"
    ```

  4. @pgilad pgilad renamed this gist Oct 23, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. @pgilad pgilad renamed this gist Oct 23, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. @pgilad pgilad renamed this gist Oct 23, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. @pgilad pgilad revised this gist Oct 23, 2014. 1 changed file with 16 additions and 1 deletion.
    17 changes: 16 additions & 1 deletion Instructions.md
    Original file line number Diff line number Diff line change
    @@ -4,4 +4,19 @@
    - make sure your delete the sample file `.git/hooks/commit-msg.sample`
    - Make commit msg executable. `chmod +x .git/hooks/commit-msg`
    - Edit `commit-msg` to better fit your development branch, commit regex and error message
    - Profit $$
    - Profit $$

    ## Shell example

    ```sh
    $ curl https://gist.githubusercontent.com/pgilad/5d7e4db725a906bd7aa7/raw/feba0ca462f87a382cfbc3eddfcc529ceb9b7350/commit-msg > .git/hooks/commit-msg

    $ rm .git/hooks/commit-msg.sample

    $ chmod +x .git/hooks/commit-msg

    $ vim .git/hooks/commit-msg

    $ echo "Profit $$"
    ```

  8. @pgilad pgilad renamed this gist Oct 23, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  9. @pgilad pgilad revised this gist Oct 23, 2014. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions Instructionsmd
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    ## Instructions

    - copy the file `commit-msg` to `.git/hooks/commit-msg`
    - make sure your delete the sample file `.git/hooks/commit-msg.sample`
    - Make commit msg executable. `chmod +x .git/hooks/commit-msg`
    - Edit `commit-msg` to better fit your development branch, commit regex and error message
    - Profit $$
  10. @pgilad pgilad created this gist Oct 23, 2014.
    16 changes: 16 additions & 0 deletions commit-msg
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/usr/bin/env bash

    # set this to your active development branch
    develop_branch="develop"
    current_branch="$(git rev-parse --abbrev-ref HEAD)"
    # regex to validate in commit msg
    commit_regex='(wap-\d+|merge)'
    error_msg="Aborting commit. Your commit message is missing either a JIRA Issue ('WAP-1111') or 'Merge'"

    # only check commit messages on main development branch
    [ "$current_branch" != "$develop_branch" ] && exit 0

    if ! grep -iqE "$commit_regex" "$1"; then
    echo "$error_msg" >&2
    exit 1
    fi