Skip to content

Commit

Permalink
Embrace Conventional Commits
Browse files Browse the repository at this point in the history
This commit adapts the contribution guidelines to be
fully Conventional Commits compatible.
changes coverity fixes to comply to Conventional Commits

It also adds clear guidelines for the commit types available.
And makes sure commits are types are checked on stylecheck

Closes #10852
Signed-off-by: Kjeld Schouten-Lebbing <[email protected]>
Requires-builders: style
  • Loading branch information
kjeld Schouten-Lebbing committed Aug 30, 2020
1 parent 0d1f125 commit 4149951
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
26 changes: 21 additions & 5 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,10 @@ git config --local core.whitespace trailing-space,space-before-tab,indent-with-n

### Commit Message Formats
#### New Changes
Commit messages for new changes must meet the following guidelines:
* In 72 characters or less, provide a summary of the change as the
Commit messages for new changes must meet the [Conventional Commits](https://www.conventionalcommits.org/) guidelines:
* In 72 characters or less, excluding the `type:` prefix, provide a summary of the change as the
first line in the commit message.
* Every header should contain a `type:` prefix. See the [Commit Types](#commit-types) section for more information
* A body which provides a description of the change. If necessary,
please summarize important information such as why the proposed
approach was chosen or a brief description of the bug you are resolving.
Expand All @@ -223,7 +224,7 @@ Each line of the body must be 72 characters or less.
An example commit message for new changes is provided below.

```
This line is a brief summary of your change
docs: This line is a brief summary of your change
Please provide at least a couple sentences describing the
change. If necessary, please summarize decisions such as
Expand All @@ -238,15 +239,15 @@ If you are submitting a fix to a
[Coverity defect](https://scan.coverity.com/projects/zfsonlinux-zfs),
the commit message should meet the following guidelines:
* Provides a subject line in the format of
`Fix coverity defects: CID dddd, dddd...` where `dddd` represents
`coverity: CID dddd, dddd...` where `dddd` represents
each CID fixed by the commit.
* Provides a body which lists each Coverity defect and how it was corrected.
* The last line must be a `Signed-off-by:` tag. See the
[Signed Off By](#signed-off-by) section for more information.

An example Coverity defect fix commit message is provided below.
```
Fix coverity defects: CID 12345, 67890
coverity: CID 12345, 67890
CID 12345: Logically dead code (DEADCODE)
Expand All @@ -260,6 +261,21 @@ Ensure free is called after allocating memory in function().
Signed-off-by: Contributor <[email protected]>
```

#### Commit Types
OpenZFS commit types to differentiate between different types of commits.
Every commit should include a type prefix in its header. Possible types:

- **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
- **ci**: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
- **docs**: Documentation only changes
- **feat**: A new feature
- **fix**: A bug fix
- **perf**: A code change that improves performance
- **refactor**: A code change that neither fixes a bug nor adds a feature
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- **test**: Adding missing tests or correcting existing tests
- **coverity**: Fixing a coverity defect. See: [Coverity Defect Fixes](#coverity-defect-fixes)

#### Signed Off By
A line tagged as `Signed-off-by:` must contain the developer's
name followed by their email. This is the developer's certification
Expand Down
8 changes: 7 additions & 1 deletion scripts/commitcheck.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

REF="HEAD"
types=(build chore ci docs feat fix perf refactor revert style coverity test)

# test a url
function test_url()
Expand Down Expand Up @@ -68,6 +69,11 @@ function check_tagged_line_with_url()
function new_change_commit()
{
error=0
type_subject=$(git log -n 1 --pretty=%s "$REF" | cut -d: -f1)
# shellcheck disable=SC2076
[[ " ${types[*]} " =~ " ${type_subject} " ]] && error=0 || error=1; \
echo "error: ${type_subject} is not a valid subject type"


# subject is not longer than 72 characters
long_subject=$(git log -n 1 --pretty=%s "$REF" | grep -E -m 1 '.{73}')
Expand Down Expand Up @@ -106,7 +112,7 @@ function coverity_fix_commit()

# subject starts with Fix coverity defects: CID dddd, dddd...
subject=$(git log -n 1 --pretty=%s "$REF" |
grep -E -m 1 'Fix coverity defects: CID [[:digit:]]+(, [[:digit:]]+)*')
grep -E -m 1 'coverity: CID [[:digit:]]+(, [[:digit:]]+)*')
if [ -z "$subject" ]; then
echo "error: Coverity defect fixes must have a subject line that starts with \"Fix coverity defects: CID dddd\""
error=1
Expand Down

0 comments on commit 4149951

Please sign in to comment.