Skip to content

Commit 021c689

Browse files
committed
git: Update gitlint to be generic
Use correct link to docs in gitlint error message. Use base-branch input instead of hardcoded main. Signed-off-by: Nicolae Dicu <[email protected]>
1 parent 0586e40 commit 021c689

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

.github/actions/gitlint/action.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ inputs:
1818
description: "Pull Request number used to fetch commits"
1919
required: true
2020
base-branch:
21-
description: "Base branch to compare commits against (default: origin/main)"
22-
default: "origin/main"
21+
description: "Base branch to compare commits against (default: main)"
22+
default: "main"
2323
required: false
2424
runs:
2525
using: "docker"
@@ -29,11 +29,12 @@ runs:
2929
- -c
3030
- |
3131
git config --global --add safe.directory /github/workspace && \
32-
git fetch origin +refs/heads/main:refs/remotes/origin/main && \
32+
git fetch origin +refs/heads/${{ inputs.base-branch }}:refs/remotes/origin/${{ inputs.base-branch }} && \
3333
git fetch origin +refs/pull/${{ inputs.pr-number }}/head && \
34-
if ! gitlint --commits origin/main..HEAD; then \
34+
if ! gitlint --commits origin/${{ inputs.base-branch }}..HEAD; then \
3535
echo -e "\nWARNING: Your commit message does not follow the required format." && \
36-
echo "Formatting rules: https://eclipse-score.github.io/score/process/guidance/git/index.html" && \
36+
echo "The tool gitlint is used to check the compliance with the rules described here:" && \
37+
echo -e "\nhttps://github.com/eclipse-score/module_template/blob/main/.gitlint" && \
3738
echo -e "To fix your commit message, run:\n" && \
3839
echo " git commit --amend" && \
3940
echo "Then update your commit (fix gitlint warnings). Finally, force-push:" && \

.gitlint

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Available rules:
2+
#
3+
# T1: title-max-length
4+
# T2: title-trailing-whitespace
5+
# T3: title-trailing-punctuation (disabled)
6+
# T4: title-hard-tab
7+
# T5: title-must-not-contain-word (disabled)
8+
# T6: title-leading-whitespace
9+
# T7: title-match-regex
10+
# B1: body-max-line-length (disabled)
11+
# B2: body-trailing-whitespace
12+
# B3: body-hard-tab
13+
# B4: body-first-line-empty
14+
# B5: body-min-length (disabled)
15+
# B6: body-is-missing
16+
# B7: body-changed-file-mention (disabled)
17+
#
18+
# See http://jorisroovers.github.io/gitlint/rules/ for a full description of the rules.
19+
20+
# Ignore some default rules and enable regex style searching
21+
[general]
22+
ignore=T3,T5,B1,B5,B7
23+
regex-style-search=true
24+
25+
# Maximum length of the title
26+
[title-max-length]
27+
line-length=72
28+
29+
[title-match-regex]
30+
regex=^[a-z_-]+: .+$
31+
32+
# First line of the commit message body must be empty. (second line of the commit message)
33+
[body-first-line-empty]
34+
35+
#Ignores the title if it starts with Revert or Merge
36+
[ignore-by-title]
37+
regex=(^Revert |^Merge )

0 commit comments

Comments
 (0)