Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sh00pdx/cdb4c07e57047cd559382cacf9a92500 to your computer and use it in GitHub Desktop.
Save sh00pdx/cdb4c07e57047cd559382cacf9a92500 to your computer and use it in GitHub Desktop.

Revisions

  1. @qoomon qoomon revised this gist Oct 26, 2022. 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
    @@ -46,6 +46,7 @@ The `scope` provides additional contextual information.
    The `subject` contains a succinct description of the change.
    * Is a **mandatory** part of the format
    * Use the imperative, present tense: "change" not "changed" nor "changes"
    * Think of `This commit will <subject>`
    * Don't capitalize the first letter
    * No dot (.) at the end

  2. @qoomon qoomon revised this gist Apr 7, 2022. 1 changed file with 3 additions and 12 deletions.
    15 changes: 3 additions & 12 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Conventinal Commit Messages
    # Conventional Commit Messages
    See how a minor change to your commit message style can make a difference. [Examples](#examples)

    **Have a look at CLI util [git-conventional-commits](https://github.com/qoomon/git-conventional-commits) to ensure this conventions and generate changelogs**
    @@ -22,21 +22,13 @@ Merge branch '<b>&lt;branch name&gt;</b>'
    </pre>
    <sup>Follows default git merge message</sup>

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

    ### Types
    * 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 special `refactor` commits, that improves performance
    * `perf` Commits are special `refactor` commits, that improve 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
    * `docs` Commits, that affect documentation only
    @@ -132,7 +124,6 @@ The `footer` should contain any information about **Breaking Changes** and is al
    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 \".+\"\$"

    zero_commit="0000000000000000000000000000000000000000"

    @@ -155,7 +146,7 @@ The `footer` should contain any information about **Breaking Changes** and is al

    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
    if ! [[ "$commit_msg_header" =~ (${commit_msg_regex})|(${merge_msg_regex}) ]]; then
    echo "$commit" >&2
    echo "ERROR: Invalid commit message format" >&2
    echo "$commit_msg_header" >&2
  3. @qoomon qoomon revised this gist Aug 6, 2021. 1 changed file with 0 additions and 5 deletions.
    5 changes: 0 additions & 5 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -97,11 +97,6 @@ The `footer` should contain any information about **Breaking Changes** and is al
    * ```
    style: remove empty line
    ```
    * ```
    revert: refactor: implement calculation method as recursion
    This reverts commit 221d3ec6ffeead67cee8c730c4a15cf8dc84897a.
    ```


    ## Git Hook Scripts to ensure commit message header format
  4. @qoomon qoomon revised this gist Apr 12, 2021. 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
    @@ -86,7 +86,7 @@ The `footer` should contain any information about **Breaking Changes** and is al
    The error occurred because of <reasons>.
    ```
    * ```
    build: release version 1.0.0
    build(release): bump version to 1.0.0
    ```
    * ```
    build: update dependencies
  5. @qoomon qoomon revised this gist Apr 12, 2021. 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
    @@ -42,6 +42,7 @@ This reverts commit <b>&lt;commit hash&gt;</b>.
    * `docs` Commits, that affect documentation only
    * `build` Commits, that affect build components like build tool, ci pipeline, dependencies, project version, ...
    * `ops` Commits, that affect operational components like infrastructure, deployment, backup, recovery, ...
    * `chore` Miscellaneous commits e.g. modifying `.gitignore`

    ### Scopes
    The `scope` provides additional contextual information.
  6. @qoomon qoomon revised this gist Apr 12, 2021. 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
    @@ -39,7 +39,7 @@ This reverts commit <b>&lt;commit hash&gt;</b>.
    * `perf` Commits are special `refactor` commits, 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
    * `docs` Commits, that affect documentation only
    * `build` Commits, that affect build components like build tool, ci pipeline, dependencies, project version, ...
    * `ops` Commits, that affect operational components like infrastructure, deployment, backup, recovery, ...

  7. @qoomon qoomon revised this gist Jan 15, 2021. 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>.
    * `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
    * `perf` Commits are special `refactor` commits, 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
  8. @qoomon qoomon revised this gist Dec 30, 2020. No changes.
  9. @qoomon qoomon revised this gist Dec 30, 2020. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -110,8 +110,15 @@ The `footer` should contain any information about **Breaking Changes** and is al
    ```shell
    #!/usr/bin/env sh

    # ensure https://github.com/qoomon/git-conventional-commits is installed
    git-conventional-commits commit-msg-hook "$1"
    commit_message="$1"
    # exit with a non zero exit code incase of an invalid commit message

    # use git-conventional-commits, see https://github.com/qoomon/git-conventional-commits
    git-conventional-commits commit-msg-hook "$commit_message"

    # or verify $commit_message with your own tooling
    # ...

    ```
    * ⚠ 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'`
  10. @qoomon qoomon revised this gist Sep 12, 2020. 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
    @@ -1,7 +1,7 @@
    # Conventinal Commit Messages
    See how a minor change to your commit message style can make a difference. [Examples](#examples)

    **Have a look at CLI Util [git-conventional-commits](https://github.com/qoomon/git-conventional-commits) to ensure this conventions and generate changelogs**
    **Have a look at CLI util [git-conventional-commits](https://github.com/qoomon/git-conventional-commits) to ensure this conventions and generate changelogs**

    <img src="https://img.icons8.com/dusk/1600/commit-git.png" width="200" height="200" />

  11. @qoomon qoomon revised this gist Sep 12, 2020. 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
    @@ -1,7 +1,7 @@
    # Conventinal Commit Messages
    See how a minor change to your commit message style can make a difference. [Examples](#examples)

    Have a look at CLI Util [git-conventional-commits](https://github.com/qoomon/git-conventional-commits)
    **Have a look at CLI Util [git-conventional-commits](https://github.com/qoomon/git-conventional-commits) to ensure this conventions and generate changelogs**

    <img src="https://img.icons8.com/dusk/1600/commit-git.png" width="200" height="200" />

  12. @qoomon qoomon revised this gist Apr 17, 2020. 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
    @@ -41,7 +41,7 @@ This reverts commit <b>&lt;commit hash&gt;</b>.
    * `test` Commits, that add missing tests or correcting existing tests
    * `doc` Commits, that affect documentation only
    * `build` Commits, that affect build components like build tool, ci pipeline, dependencies, project version, ...
    * `ops` Commits, that affect operational components like infrastructure, backup, recovery, ...
    * `ops` Commits, that affect operational components like infrastructure, deployment, backup, recovery, ...

    ### Scopes
    The `scope` provides additional contextual information.
  13. @qoomon qoomon revised this gist Sep 26, 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
    @@ -1,5 +1,6 @@
    # Conventinal Commit Messages
    See how a minor change to your commit message style can make a difference. [Examples](#examples)

    Have a look at CLI Util [git-conventional-commits](https://github.com/qoomon/git-conventional-commits)

    <img src="https://img.icons8.com/dusk/1600/commit-git.png" width="200" height="200" />
  14. @qoomon qoomon revised this gist Sep 26, 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
    @@ -1,5 +1,6 @@
    # Conventinal Commit Messages
    See how a minor change to your commit message style can make a difference. [Examples](#examples)
    Have a look at CLI Util [git-conventional-commits](https://github.com/qoomon/git-conventional-commits)

    <img src="https://img.icons8.com/dusk/1600/commit-git.png" width="200" height="200" />

  15. @qoomon qoomon revised this gist Sep 26, 2019. 1 changed file with 3 additions and 16 deletions.
    19 changes: 3 additions & 16 deletions conventional_commit_messages.md
    Original file line number Diff line number Diff line change
    @@ -107,22 +107,9 @@ The `footer` should contain any information about **Breaking Changes** and is al
    * create following file in your local repository folder`.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|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

    # ensure https://github.com/qoomon/git-conventional-commits is installed
    git-conventional-commits commit-msg-hook "$1"
    ```
    * ⚠ 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'`
  16. @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
  17. @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
  18. @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.
  19. @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

  20. @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`
  21. @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.
  22. @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`
  23. @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`
  24. @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

  25. @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
  26. @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

  27. @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
  28. @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'`

  29. @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`
  30. @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