Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saveroo/16756e2978e61b152bfab6edd600e5d7 to your computer and use it in GitHub Desktop.
Save saveroo/16756e2978e61b152bfab6edd600e5d7 to your computer and use it in GitHub Desktop.

Revisions

  1. @qoomon qoomon revised this gist Jul 1, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -64,7 +64,7 @@ The `body` should include the motivation for the change and contrast this with p
    The `footer` should contain any information about **Breaking Changes** and is also the place to **reference Issues** that this commit refers to.
    * Is an **optional** part of the format
    * **optionally** reference an issue by its id.
    * **Breaking Changes** should start with the word `BREAKING CHANGES:` folowed by space or two newlines. The rest of the commit message is then used for this.
    * **Breaking Changes** should start with the word `BREAKING CHANGES:` followed by space or two newlines. The rest of the commit message is then used for this.


    ### Examples
  2. @qoomon qoomon revised this gist Jul 1, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -64,7 +64,7 @@ The `body` should include the motivation for the change and contrast this with p
    The `footer` should contain any information about **Breaking Changes** and is also the place to **reference Issues** that this commit refers to.
    * Is an **optional** part of the format
    * **optionally** reference an issue by its id.
    * **Breaking Changes** should start with the word `BREAKING CHANGE:` folowed by space or two newlines. The rest of the commit message is then used for this.
    * **Breaking Changes** should start with the word `BREAKING CHANGES:` folowed by space or two newlines. The rest of the commit message is then used for this.


    ### Examples
    @@ -75,7 +75,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    feat: remove ticket list endpoint
    refers to JIRA-1337
    BREAKING CHANGE: ticket enpoints no longer supports list all entites.
    BREAKING CHANGES: ticket enpoints no longer supports list all entites.
    ```
    * ```
    fix: add missing parameter to service call
  3. @qoomon qoomon revised this gist Jul 1, 2019. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -30,15 +30,16 @@ This reverts commit <b>&lt;commit hash&gt;</b>.
    <sup>Follows default git revert message</sup>

    ### Types
    * `feat` Commits, that adds a new feature, **recognizable by your clients**
    * `fix` Commits, that fixes a bug, **recognizable by your clients**
    * `perf` Commits, that improves performance, **recognizable by your clients**
    * API relevant changes
    * `feat` Commits, that adds a new feature
    * `fix` Commits, that fixes a bug
    * `refactor` Commits, that rewrite/restructure your code, however does not change any behaviour
    * `perf` Commits are `refactor` commit, that improves performance
    * `style` Commits, that do not affect the meaning (white-space, formatting, missing semi-colons, etc)
    * `test` Commits, that add missing tests or correcting existing tests
    * `doc` Commits, that affect documentation only
    * `build` Commits, that affect the build system or external dependencies
    * `ops` Commits, that affect operational components like infrastructure, backup or recovery
    * `build` Commits, that affect build components like build tool, ci pipeline, dependencies, project version, ...
    * `ops` Commits, that affect operational components like infrastructure, backup, recovery, ...

    ### Scopes
    The `scope` provides additional contextual information.
  4. @qoomon qoomon revised this gist Jul 1, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,7 @@ This reverts commit <b>&lt;commit hash&gt;</b>.
    * `refactor` Commits, that rewrite/restructure your code, however does not change any behaviour
    * `style` Commits, that do not affect the meaning (white-space, formatting, missing semi-colons, etc)
    * `test` Commits, that add missing tests or correcting existing tests
    * `docs` Commits, that affect documentation only
    * `doc` Commits, that affect documentation only
    * `build` Commits, that affect the build system or external dependencies
    * `ops` Commits, that affect operational components like infrastructure, backup or recovery

  5. @qoomon qoomon revised this gist Jun 25, 2019. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -103,7 +103,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    ## Git Hook Scripts to ensure commit message header format

    ### commit-msg Hook (local)
    * create following file in your local repository folder`.githooks/commit-msg`
    * create following file in your local repository folder`.git-hooks/commit-msg`
    ```shell
    #!/usr/bin/env sh

    @@ -123,9 +123,9 @@ The `footer` should contain any information about **Breaking Changes** and is al
    exit 1
    fi
    ```
    * ⚠ make `.githooks/commit-msg` executable (unix: `chmod +x '.githooks/commit-msg'`)
    * set git hook directory to `.githooks` `git config core.hooksPath '.githooks'`
    * commit `.githooks` directory if you want to share them with your team, they only need to call the git config command once after cloning the repository
    * ⚠ make `.git-hooks/commit-msg` executable (unix: `chmod +x '.git-hooks/commit-msg'`)
    * set git hook directory to `.githooks` `git config core.hooksPath '.git-hooks'`
    * commit `.git-hooks` directory if you want to share them with your team, they only need to call the git config command once after cloning the repository

    ### pre-receive Hook (server side)
    * create following file in your repository folder `.git/hooks/pre-receive`
  6. @qoomon qoomon revised this gist May 27, 2019. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -30,15 +30,15 @@ This reverts commit <b>&lt;commit hash&gt;</b>.
    <sup>Follows default git revert message</sup>

    ### Types
    * `feat` A code change that adds a new feature
    * `fix` A code change that adds a bug fix
    * `refactor` A code change that neither adds a new feature nor fixes a bug
    * `style` A code change that do not affect the meaning (white-space, formatting, missing semi-colons, etc)
    * `test` Changes that add missing tests or correcting existing tests
    * `docs` Changes that affect documentation only
    * `build` Changes that affect the build system or external dependencies
    * `ops` Changes that affect operational components like infrastructure, backup or recovery

    * `feat` Commits, that adds a new feature, **recognizable by your clients**
    * `fix` Commits, that fixes a bug, **recognizable by your clients**
    * `perf` Commits, that improves performance, **recognizable by your clients**
    * `refactor` Commits, that rewrite/restructure your code, however does not change any behaviour
    * `style` Commits, that do not affect the meaning (white-space, formatting, missing semi-colons, etc)
    * `test` Commits, that add missing tests or correcting existing tests
    * `docs` Commits, that affect documentation only
    * `build` Commits, that affect the build system or external dependencies
    * `ops` Commits, that affect operational components like infrastructure, backup or recovery

    ### Scopes
    The `scope` provides additional contextual information.
  7. @qoomon qoomon revised this gist May 2, 2019. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -103,7 +103,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    ## Git Hook Scripts to ensure commit message header format

    ### commit-msg Hook (local)
    * create following file in your local repository folder`.git-hooks/commit-msg`
    * create following file in your local repository folder`.githooks/commit-msg`
    ```shell
    #!/usr/bin/env sh

    @@ -123,8 +123,9 @@ The `footer` should contain any information about **Breaking Changes** and is al
    exit 1
    fi
    ```
    * ⚠ make `.git-hooks/commit-msg` executable (unix: `chmod +x '.git-hooks/commit-msg'`)
    * set git hook directory to `.git-hooks` `git config core.hooksPath '.git-hooks'`
    * ⚠ make `.githooks/commit-msg` executable (unix: `chmod +x '.githooks/commit-msg'`)
    * set git hook directory to `.githooks` `git config core.hooksPath '.githooks'`
    * commit `.githooks` directory if you want to share them with your team, they only need to call the git config command once after cloning the repository

    ### pre-receive Hook (server side)
    * create following file in your repository folder `.git/hooks/pre-receive`
  8. @qoomon qoomon revised this gist Apr 30, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -124,7 +124,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    fi
    ```
    * ⚠ make `.git-hooks/commit-msg` executable (unix: `chmod +x '.git-hooks/commit-msg'`)
    * set commit hook directory to `.git-hooks` `git config core.hooksPath '.git-hooks'`
    * set git hook directory to `.git-hooks` `git config core.hooksPath '.git-hooks'`

    ### pre-receive Hook (server side)
    * create following file in your repository folder `.git/hooks/pre-receive`
  9. @qoomon qoomon revised this gist Apr 30, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -103,7 +103,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    ## Git Hook Scripts to ensure commit message header format

    ### commit-msg Hook (local)
    * create following file `.git-hooks/commit-msg`
    * create following file in your local repository folder`.git-hooks/commit-msg`
    ```shell
    #!/usr/bin/env sh

    @@ -127,7 +127,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    * set commit hook directory to `.git-hooks` `git config core.hooksPath '.git-hooks'`

    ### pre-receive Hook (server side)
    * create following file `.git/hooks/pre-receive`
    * create following file in your repository folder `.git/hooks/pre-receive`
    ```shell
    #!/usr/bin/env sh

  10. @qoomon qoomon revised this gist Apr 30, 2019. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -103,7 +103,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    ## Git Hook Scripts to ensure commit message header format

    ### commit-msg Hook (local)
    * create following file `.git-hooks/commit-msg` and ⚠ make it executable (unix: `chmod +x '.git-hooks/commit-msg'`)
    * create following file `.git-hooks/commit-msg`
    ```shell
    #!/usr/bin/env sh

    @@ -123,10 +123,11 @@ The `footer` should contain any information about **Breaking Changes** and is al
    exit 1
    fi
    ```
    * ⚠ make `.git-hooks/commit-msg` executable (unix: `chmod +x '.git-hooks/commit-msg'`)
    * set commit hook directory to `.git-hooks` `git config core.hooksPath '.git-hooks'`

    ### pre-receive Hook (server side)
    * create following file `.git/hooks/pre-receive` and ⚠ make it executable (unix: `chmod +x '.git/hooks/pre-receive'`)
    * create following file `.git/hooks/pre-receive`
    ```shell
    #!/usr/bin/env sh

    @@ -173,6 +174,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    exit 1
    fi
    ```
    * ⚠ make `.git/hooks/pre-receive` executable (unix: `chmod +x '.git/hooks/pre-receive'`)

    -----
    ## References
  11. @qoomon qoomon revised this gist Apr 30, 2019. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -103,7 +103,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    ## Git Hook Scripts to ensure commit message header format

    ### commit-msg Hook (local)
    * create following file `.git-hooks/commit-msg`
    * create following file `.git-hooks/commit-msg` and ⚠ make it executable (unix: `chmod +x '.git-hooks/commit-msg'`)
    ```shell
    #!/usr/bin/env sh

    @@ -123,11 +123,10 @@ The `footer` should contain any information about **Breaking Changes** and is al
    exit 1
    fi
    ```
    * ⚠ make `.git-hooks/commit-msg` executable (unix: `chmod +x .git-hooks/commit-msg`)
    * set commit hook directory to `.git-hooks` `git config core.hooksPath '.git-hooks'`

    ### pre-receive Hook (server side)
    * create following file `.git/hooks/pre-receive`
    * create following file `.git/hooks/pre-receive` and ⚠ make it executable (unix: `chmod +x '.git/hooks/pre-receive'`)
    ```shell
    #!/usr/bin/env sh

  12. @qoomon qoomon revised this gist Apr 30, 2019. 1 changed file with 37 additions and 38 deletions.
    75 changes: 37 additions & 38 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -128,53 +128,52 @@ The `footer` should contain any information about **Breaking Changes** and is al

    ### pre-receive Hook (server side)
    * create following file `.git/hooks/pre-receive`
    ```shell
    #!/usr/bin/env sh

    # Pre-receive hook that will block commits with messges that do not follow regex rule
    ```shell
    #!/usr/bin/env sh

    commit_msg_type_regex='feat|fix|refactor|style|test|docs|build'
    commit_msg_scope_regex='.{1,20}'
    commit_msg_subject_regex='.{1,100}'
    commit_msg_regex="^(${commit_msg_type_regex})(\(${commit_msg_scope_regex}\))?: (${commit_msg_subject_regex})\$"
    merge_msg_regex="^Merge branch '.+'\$"
    revert_msg_regex="^Revert \".+\"\$"
    # Pre-receive hook that will block commits with messges that do not follow regex rule

    zero_commit="0000000000000000000000000000000000000000"
    commit_msg_type_regex='feat|fix|refactor|style|test|docs|build'
    commit_msg_scope_regex='.{1,20}'
    commit_msg_subject_regex='.{1,100}'
    commit_msg_regex="^(${commit_msg_type_regex})(\(${commit_msg_scope_regex}\))?: (${commit_msg_subject_regex})\$"
    merge_msg_regex="^Merge branch '.+'\$"
    revert_msg_regex="^Revert \".+\"\$"

    # Do not traverse over commits that are already in the repository
    excludeExisting="--not --all"
    zero_commit="0000000000000000000000000000000000000000"

    error=""
    while read oldrev newrev refname; do
    # branch or tag get deleted
    if [ "$newrev" = "$zero_commit" ]; then
    continue
    fi
    # Do not traverse over commits that are already in the repository
    excludeExisting="--not --all"

    # Check for new branch or tag
    if [ "$oldrev" = "$zero_commit" ]; then
    rev_span=`git rev-list $newrev $excludeExisting`
    else
    rev_span=`git rev-list $oldrev..$newrev $excludeExisting`
    fi
    error=""
    while read oldrev newrev refname; do
    # branch or tag get deleted
    if [ "$newrev" = "$zero_commit" ]; then
    continue
    fi

    for commit in $rev_span; do
    commit_msg_header=$(git show -s --format=%s $commit)
    if ! [[ "$commit_msg_header" =~ (${commit_msg_regex})|(${merge_msg_regex})|(${revert_msg_regex}) ]]; then
    echo "$commit" >&2
    echo "ERROR: Invalid commit message format" >&2
    echo "$commit_msg_header" >&2
    error="true"
    # Check for new branch or tag
    if [ "$oldrev" = "$zero_commit" ]; then
    rev_span=`git rev-list $newrev $excludeExisting`
    else
    rev_span=`git rev-list $oldrev..$newrev $excludeExisting`
    fi
    done
    done

    if [ -n "$error" ]; then
    exit 1
    fi
    for commit in $rev_span; do
    commit_msg_header=$(git show -s --format=%s $commit)
    if ! [[ "$commit_msg_header" =~ (${commit_msg_regex})|(${merge_msg_regex})|(${revert_msg_regex}) ]]; then
    echo "$commit" >&2
    echo "ERROR: Invalid commit message format" >&2
    echo "$commit_msg_header" >&2
    error="true"
    fi
    done
    done

    ```
    if [ -n "$error" ]; then
    exit 1
    fi
    ```

    -----
    ## References
  13. @qoomon qoomon revised this gist Apr 30, 2019. 1 changed file with 19 additions and 19 deletions.
    38 changes: 19 additions & 19 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -104,25 +104,25 @@ The `footer` should contain any information about **Breaking Changes** and is al

    ### commit-msg Hook (local)
    * create following file `.git-hooks/commit-msg`
    ```shell
    #!/usr/bin/env sh

    # commit-msg hook that will ensure commit messge format

    commit_msg_type_regex='feat|fix|refactor|style|test|docs|build'
    commit_msg_scope_regex='.{1,20}'
    commit_msg_subject_regex='.{1,100}'
    commit_msg_regex="^(${commit_msg_type_regex})(\(${commit_msg_scope_regex}\))?: (${commit_msg_subject_regex})\$"
    merge_msg_regex="^Merge branch '.+'\$"
    revert_msg_regex="^Revert \".+\"\$"

    commit_msg_header=$(head -1 $1)
    if ! [[ "$commit_msg_header" =~ (${commit_msg_regex})|(${merge_msg_regex})|(${revert_msg_regex}) ]]; then
    echo "ERROR: Invalid commit message format" >&2
    echo "\n$commit_msg_header" >&2
    exit 1
    fi
    ```
    ```shell
    #!/usr/bin/env sh

    # commit-msg hook that will ensure commit messge format

    commit_msg_type_regex='feat|fix|refactor|style|test|docs|build|ops'
    commit_msg_scope_regex='.{1,20}'
    commit_msg_subject_regex='.{1,100}'
    commit_msg_regex="^(${commit_msg_type_regex})(\(${commit_msg_scope_regex}\))?: (${commit_msg_subject_regex})\$"
    merge_msg_regex="^Merge branch '.+'\$"
    revert_msg_regex="^Revert \".+\"\$"

    commit_msg_header=$(head -1 $1)
    if ! [[ "$commit_msg_header" =~ (${commit_msg_regex})|(${merge_msg_regex})|(${revert_msg_regex}) ]]; then
    echo "ERROR: Invalid commit message format" >&2
    echo "\n$commit_msg_header" >&2
    exit 1
    fi
    ```
    * ⚠ make `.git-hooks/commit-msg` executable (unix: `chmod +x .git-hooks/commit-msg`)
    * set commit hook directory to `.git-hooks` `git config core.hooksPath '.git-hooks'`

  14. @qoomon qoomon revised this gist Apr 30, 2019. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -103,7 +103,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    ## Git Hook Scripts to ensure commit message header format

    ### commit-msg Hook (local)
    * create following file `.git-hooks/commit-msg` and make it executable (unix: `chmod +x .git-hooks/commit-msg`)
    * create following file `.git-hooks/commit-msg`
    ```shell
    #!/usr/bin/env sh

    @@ -123,7 +123,8 @@ if ! [[ "$commit_msg_header" =~ (${commit_msg_regex})|(${merge_msg_regex})|(${re
    exit 1
    fi
    ```
    * set commit hook directory `git config core.hooksPath ".git-hooks"`
    * ⚠ make `.git-hooks/commit-msg` executable (unix: `chmod +x .git-hooks/commit-msg`)
    * set commit hook directory to `.git-hooks` `git config core.hooksPath '.git-hooks'`

    ### pre-receive Hook (server side)
    * create following file `.git/hooks/pre-receive`
  15. @qoomon qoomon revised this gist Apr 30, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -103,7 +103,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    ## Git Hook Scripts to ensure commit message header format

    ### commit-msg Hook (local)
    * create following file `.git-hooks/commit-msg` and make it executable
    * create following file `.git-hooks/commit-msg` and make it executable (unix: `chmod +x .git-hooks/commit-msg`)
    ```shell
    #!/usr/bin/env sh

  16. @qoomon qoomon revised this gist Apr 15, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -103,7 +103,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    ## Git Hook Scripts to ensure commit message header format

    ### commit-msg Hook (local)
    * create following file `.git-hooks/hooks/commit-msg` and make it executable
    * create following file `.git-hooks/commit-msg` and make it executable
    ```shell
    #!/usr/bin/env sh

  17. @qoomon qoomon revised this gist Apr 15, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -103,8 +103,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    ## Git Hook Scripts to ensure commit message header format

    ### commit-msg Hook (local)
    * set commit hook directory `git config core.hooksPath ".git-hooks"`
    * create following file `.git-hooks/hooks/commit-msg`
    * create following file `.git-hooks/hooks/commit-msg` and make it executable
    ```shell
    #!/usr/bin/env sh

    @@ -124,6 +123,7 @@ if ! [[ "$commit_msg_header" =~ (${commit_msg_regex})|(${merge_msg_regex})|(${re
    exit 1
    fi
    ```
    * set commit hook directory `git config core.hooksPath ".git-hooks"`

    ### pre-receive Hook (server side)
    * create following file `.git/hooks/pre-receive`
  18. @qoomon qoomon revised this gist Apr 15, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -102,7 +102,7 @@ The `footer` should contain any information about **Breaking Changes** and is al

    ## Git Hook Scripts to ensure commit message header format

    ### commit-msg Hook (server side)
    ### commit-msg Hook (local)
    * set commit hook directory `git config core.hooksPath ".git-hooks"`
    * create following file `.git-hooks/hooks/commit-msg`
    ```shell
  19. @qoomon qoomon revised this gist Apr 15, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -44,6 +44,7 @@ This reverts commit <b>&lt;commit hash&gt;</b>.
    The `scope` provides additional contextual information.
    * Is an **optional** part of the format
    * Allowed Scopes depends on the specific project
    * Don't use issue identifiers as scopes

    ### Subject
    The `subject` contains a succinct description of the change.
    @@ -56,6 +57,7 @@ The `subject` contains a succinct description of the change.
    The `body` should include the motivation for the change and contrast this with previous behavior.
    * Is an **optional** part of the format
    * Use the imperative, present tense: "change" not "changed" nor "changes"
    * This is the place to mention issue identifiers and their relations

    ### Footer
    The `footer` should contain any information about **Breaking Changes** and is also the place to **reference Issues** that this commit refers to.
  20. @qoomon qoomon revised this gist Apr 8, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -124,7 +124,7 @@ fi
    ```

    ### pre-receive Hook (server side)
    `.git/hooks/pre-receive`
    * create following file `.git/hooks/pre-receive`
    ```shell
    #!/usr/bin/env sh

  21. @qoomon qoomon revised this gist Apr 8, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -101,7 +101,8 @@ The `footer` should contain any information about **Breaking Changes** and is al
    ## Git Hook Scripts to ensure commit message header format

    ### commit-msg Hook (server side)
    `.git/hooks/commit-msg`
    * set commit hook directory `git config core.hooksPath ".git-hooks"`
    * create following file `.git-hooks/hooks/commit-msg`
    ```shell
    #!/usr/bin/env sh

  22. @qoomon qoomon revised this gist Apr 8, 2019. 1 changed file with 33 additions and 8 deletions.
    41 changes: 33 additions & 8 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -98,18 +98,43 @@ The `footer` should contain any information about **Breaking Changes** and is al
    ```


    ## Git Prereceive Hook Script to ensure commit message header format
    ```bash
    #!/usr/bin/env bash
    ## Git Hook Scripts to ensure commit message header format

    ### commit-msg Hook (server side)
    `.git/hooks/commit-msg`
    ```shell
    #!/usr/bin/env sh

    # commit-msg hook that will ensure commit messge format

    commit_msg_type_regex='feat|fix|refactor|style|test|docs|build'
    commit_msg_scope_regex='.{1,20}'
    commit_msg_subject_regex='.{1,100}'
    commit_msg_regex="^(${commit_msg_type_regex})(\(${commit_msg_scope_regex}\))?: (${commit_msg_subject_regex})\$"
    merge_msg_regex="^Merge branch '.+'\$"
    revert_msg_regex="^Revert \".+\"\$"

    commit_msg_header=$(head -1 $1)
    if ! [[ "$commit_msg_header" =~ (${commit_msg_regex})|(${merge_msg_regex})|(${revert_msg_regex}) ]]; then
    echo "ERROR: Invalid commit message format" >&2
    echo "\n$commit_msg_header" >&2
    exit 1
    fi
    ```

    ### pre-receive Hook (server side)
    `.git/hooks/pre-receive`
    ```shell
    #!/usr/bin/env sh

    #
    # Pre-receive hook that will block commits with messges that do not follow regex rule
    #

    commit_msg_type_regex='(feat|fix|refactor|style|test|docs|build)'
    commit_msg_type_regex='feat|fix|refactor|style|test|docs|build'
    commit_msg_scope_regex='.{1,20}'
    commit_msg_subject_regex='.{1,100}'
    commit_msg_header_regex="^${commit_msg_type_regex}(\(${commit_msg_scope_regex}\))?: ${commit_msg_subject_regex}$|^Merge branch '.+'$|^(^Revert ".+"$)?|"
    commit_msg_regex="^(${commit_msg_type_regex})(\(${commit_msg_scope_regex}\))?: (${commit_msg_subject_regex})\$"
    merge_msg_regex="^Merge branch '.+'\$"
    revert_msg_regex="^Revert \".+\"\$"

    zero_commit="0000000000000000000000000000000000000000"

    @@ -132,7 +157,7 @@ while read oldrev newrev refname; do

    for commit in $rev_span; do
    commit_msg_header=$(git show -s --format=%s $commit)
    if ! [[ "$commit_msg_header" =~ ${commit_msg_header_regex} ]]; then
    if ! [[ "$commit_msg_header" =~ (${commit_msg_regex})|(${merge_msg_regex})|(${revert_msg_regex}) ]]; then
    echo "$commit" >&2
    echo "ERROR: Invalid commit message format" >&2
    echo "$commit_msg_header" >&2
  23. @qoomon qoomon revised this gist Feb 4, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -37,6 +37,7 @@ This reverts commit <b>&lt;commit hash&gt;</b>.
    * `test` Changes that add missing tests or correcting existing tests
    * `docs` Changes that affect documentation only
    * `build` Changes that affect the build system or external dependencies
    * `ops` Changes that affect operational components like infrastructure, backup or recovery


    ### Scopes
  24. @qoomon qoomon revised this gist Jan 31, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -108,7 +108,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    commit_msg_type_regex='(feat|fix|refactor|style|test|docs|build)'
    commit_msg_scope_regex='.{1,20}'
    commit_msg_subject_regex='.{1,100}'
    commit_msg_header_regex="^Merge branch '.+'$|^(^Revert ".+"$)?|${commit_msg_type_regex}(\(${commit_msg_scope_regex}\))?: ${commit_msg_subject_regex}$"
    commit_msg_header_regex="^${commit_msg_type_regex}(\(${commit_msg_scope_regex}\))?: ${commit_msg_subject_regex}$|^Merge branch '.+'$|^(^Revert ".+"$)?|"

    zero_commit="0000000000000000000000000000000000000000"

  25. @qoomon qoomon revised this gist Jan 31, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -108,7 +108,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    commit_msg_type_regex='(feat|fix|refactor|style|test|docs|build)'
    commit_msg_scope_regex='.{1,20}'
    commit_msg_subject_regex='.{1,100}'
    commit_msg_header_regex="^Merge .+$|^(revert: )?${commit_msg_type_regex}(\(${commit_msg_scope_regex}\))?: ${commit_msg_subject_regex}$"
    commit_msg_header_regex="^Merge branch '.+'$|^(^Revert ".+"$)?|${commit_msg_type_regex}(\(${commit_msg_scope_regex}\))?: ${commit_msg_subject_regex}$"

    zero_commit="0000000000000000000000000000000000000000"

  26. @qoomon qoomon revised this gist Jan 31, 2019. No changes.
  27. @qoomon qoomon revised this gist Jan 31, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ See how a minor change to your commit message style can make a difference. [Exam

    ### Merge
    <pre>
    Merge branch '<b><a href="#merge">&lt;branch name&gt;</a></b>'
    Merge branch '<b>&lt;branch name&gt;</b>'
    </pre>
    <sup>Follows default git merge message</sup>

  28. @qoomon qoomon revised this gist Jan 31, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ See how a minor change to your commit message style can make a difference. [Exam

    ### Merge
    <pre>
    Merge branch <b>'<a href="#merge">&lt;branch name&gt;</a>'</b>
    Merge branch '<b><a href="#merge">&lt;branch name&gt;</a></b>'
    </pre>
    <sup>Follows default git merge message</sup>

  29. @qoomon qoomon revised this gist Jan 31, 2019. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -7,11 +7,11 @@ See how a minor change to your commit message style can make a difference. [Exam

    ### Default
    <pre>
    <b><a href="#types">&lt;type&gt;</a></font>(<a href="#scopes">&lt;optional scope&gt;</a>): <a href="#subject">&lt;subject&gt;</a></b>
    <b><a href="#types">&lt;type&gt;</a></b></font>(<b><a href="#scopes">&lt;optional scope&gt;</a></b>): <b><a href="#subject">&lt;subject&gt;</a></b>
    <sub>empty separator line</sub>
    <b>&lt;<a href="#body">optional body</a>></b>
    <b><a href="#body">&lt;optional body&gt;</a></b>
    <sub>empty separator line</sub>
    <b>&lt;<a href="#footer">optional footer</a>></b>
    <b><a href="#footer">&lt;optional footer&gt;</a></b>
    </pre>

    ### Merge
  30. @qoomon qoomon revised this gist Jan 31, 2019. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -22,10 +22,10 @@ Merge branch <b>'<a href="#merge">&lt;branch name&gt;</a>'</b>

    ### Revert
    <pre>
    Revert <b>"<a href="#revert">&lt;commit headline&gt;</a>"</b>
    Revert "<b>&lt;commit headline&gt;</b>"
    <sub>empty separator line</sub>
    This reverts commit <b><a href="#revert">&lt;commit hash&gt;</a>.</b>
    <b><a href="#revert">&lt;optinal reason&gt;</a></b>
    This reverts commit <b>&lt;commit hash&gt;</b>.
    <b>&lt;optinal reason&gt;</b>
    </pre>
    <sup>Follows default git revert message</sup>