Commit graph

23 commits

Author SHA1 Message Date
Anas Nashif 66af7a6881 gitlint: do not allow treewide as an area in commit messages
Treewide changes touching a single area or topic should have the
area/subsystem at the start of the commit message. Treewide is very
ambigous.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-04-10 09:22:24 +02:00
Anas Nashif 9e87bd7ad6 gitlint: exclude long line with co-authored-by
Treat co-authored-by like signed-off-by.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-09-27 06:20:16 -04:00
Marc Herbert 8e7c7c62b1 .gitlint: de-duplicate defaults with zephyr_commit_rules.py
We don't need to have two different sets of Zephyr-specific default
values overriding one another, it's confusing.

Note this commit makes NO functional change, the effective defaults stay
the same. It does however make it easier to change defaults in the
future.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-09-21 09:29:24 +02:00
Marti Bolivar 2149d2127a scripts: zephyr_commit_rules: improve commit error messages
Make the error messages which appear in CI for invalid commit messages
match the text in the documentation which describes the rules for
commit messages exactly. This hopefully makes it easier for people to
read failing CI results and map them to documentation links describing
what to do instead.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-02-08 15:03:56 -08:00
Tristan Honscheid ae97971a61 gitlint: Add "commit" to violation messages
This PR clarifies the violation messages emitted by gitlint when
checking the commit message. For example:

 * Before: `43: UC4 Line exceeds max length (N>75): "..."`
 * After: `43: UC4 Commit line exceeds max length (N>75): "..."`

This makes it easier to identify the source of the error since there is
currently no additional context besides the error code UC*. I recently
pushed a commit that had some sample code as part of the commit body
that exceeded the lenght limit, and thought the error was referring to
one of my source files based on the line it showed. (feel free to laugh
at me, but let's make it better for the next person)

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2022-12-07 07:58:05 -05:00
Fabio Baltieri d42b2e6bed scripts: gitlint: block Change-Id tags in commit message
Add a new gitlint user rule to block unwanted commit tags, and set it up
to block Gerrit Change-Id tags.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-04-20 20:59:33 -04:00
Ulf Magnusson 1c57b223ef zephyr_commit_rules.py: Fix pylint warning by simplifying conditional
Non-empty sequences are truthy in Python, so len() can be skipped in
tests.

Fixes this pylint warning:

    scripts/gitlint/zephyr_commit_rules.py:115:11: C1801: Do not use
    `len(SEQUENCE)` to determine if a sequence is empty
    (len-as-condition)

Fixing warnings for a CI check.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-08 22:19:37 -04:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Ulf Magnusson a449c98db2 scripts: Fix risky uses of non-raw regex strings in Python scripts
Fixes pylint warnings like this one:

    doc/conf.py:325:0: W1401: Anomalous backslash in string: '\s'.
    String constant might be missing an r prefix.
    (anomalous-backslash-in-string)

The reason for this warning is that backslash escapes are interpreted in
non-raw (non-r-prefixed) strings. For example, '\a' and r'\a' are not
the same string (first one has a single ASCII bell character, second one
has two characters).

It just happens that there's no \s (or \., or \/) escape for example,
and '\s' turns into two characters (as needed for a regex). It's risky
to rely on stuff like that regexes though. Best to make them raw strings
unless they're super trivial.

Also note that '\s' and '\\s' turn into the same string.

Another tip: A literal ' can be put into a string with "blah'blah"
instead of 'blah\'blah'.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-28 14:41:32 -05:00
Ulf Magnusson d5b0bd14e3 scripts: Remove unused imports in all Python scripts
Discovered with pylint3.

Upstream open-amp PR: https://github.com/OpenAMP/open-amp/pull/168

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-28 11:06:20 -05:00
Ulf Magnusson 7da0053a0c scripts: gitlint: Fix broken module docstring
Needs to be at the beginning of the file. Fixes a pylint warning:

    scripts/process_gperf.py:26:-1: W0105: String statement has no
    effect (pointless-string-statement)

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-26 07:50:06 -05:00
Paul Sokolovsky 26e562c0bd scripts: gitlint: Consistent case for Signed-off-by
The commit header as added by "git commit -s" is "Signed-off-by:",
and not any other casing. While it perhaps case-insensitive, use
canonical casing to not confuse (attentive) users.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-02-19 12:12:42 -05:00
Anas Nashif 8d84f9229c gitlint: do not start with subsys:
Commit messages should not start with literal "subsys:", instead, spell
out the actual subsystem name.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-11-28 09:22:01 -08:00
Anas Nashif 0f55538762 gitlint: accept "'" in committer names
Allow "'" in names, for example xxx O'xxx.

Fixes #10152

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-09-21 12:49:23 -04:00
Anas Nashif abfed53525 gitlint: fix check for line_count
We should check if the commits line is less than, not less/equal...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-11 10:48:03 -05:00
Anas Nashif 2dd5cef811 gitlint: do not allow title-only commit messages
It has been agreed in the project TSC to reject commit messages without
any content. Every commit message needs some explaination beyond what
was put in the title, even the most trivial ones.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-11 06:39:42 -05:00
Anas Nashif 789d51c4aa ci: do not treat message parts as xml
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-28 09:00:50 -04:00
Anas Nashif 87766a25c6 gitlint: ignore titles prefixed with Revert
The revert commit title is usually prefixed with "Revert" which causes
the title to become longer than the allowed limit. Allow such commits to
keep revert commits consistent with the original commit message.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-08 09:04:25 -04:00
Anas Nashif 408a61d42b gitlint: tolerate long lines with URLs
When including referecnes to external resources using a URL, keep the
line with URL in one line to not break the link and allow this to pass
the gitlint test.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-08 09:04:25 -04:00
Anas Nashif b520075788 gitlint: Ignore signed-off-by line
When checking for line length limits, ignore lines with Signed-off-by.
Some developers have a long name that would not fit within the limits.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-06 09:35:50 -04:00
Anas Nashif 3c27c46562 gitlint: check for subsystem in commit subject
Check that we have <subsystem>: <subject> in commit messages.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-05-19 20:04:08 -04:00
Anas Nashif 1338f49206 gitlint: verify full name in signed-off-by line
Make sure we get full name in the commit message and not the username or
some incomplete data that we need to decipher. We still need to verify
the commiter name that is not part of the commit message body, but this
is out of scope of gitlint.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-05-05 16:11:11 -05:00
Anas Nashif a35378e494 scripts: add gitlint to check for validity of commit messages
Install gitlint using pip:

 # pip install gitlint
 # gitlint install-hook

This will install the pre-commit hook.

Policies are define in .gitlint. Custom rules are available under
scripts/gitlint.

This script will also run in CI, so avoid CI errors by using the hook
above.

Change-Id: I62750a1fd9369341db29c413a6c4a1677bb0db8a
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-04-25 22:48:24 +00:00