Skip to content

Commit 8669b8e

Browse files
authored
Merge pull request #135 from SADiLaR/ci/lint-commits
chore(ci): lint for bang commits (fixup, squash, drop, edit)
2 parents 1c02a68 + 1d54ae8 commit 8669b8e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

.github/workflows/testing.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,28 @@ jobs:
117117
with:
118118
name: django-logs
119119
path: app/debug.log
120+
lint-commits:
121+
runs-on: ubuntu-latest
122+
if: github.event.ref != 'refs/heads/main'
123+
124+
steps:
125+
- uses: actions/checkout@v4
126+
with:
127+
fetch-depth: 0
128+
- name: Get all commits on current main
129+
run: git fetch origin main
130+
- name: Log all commits we will analyse
131+
run: git log --pretty=format:%s origin/main..HEAD
132+
133+
# - We use -v here, which inverts the match, because we want to output an exit status of 1 when a match _is_
134+
# found (usually 0 is for a match)
135+
# - We use a -z here, which makes \0 be the line separator, because if feeding multiline text into grep, it will
136+
# exit with a status of 0 regardless of whether there is a match (so, -z makes it treat the input as one line)
137+
- name: Disallow fixup commits
138+
run: git log --pretty=format:%s origin/main..HEAD | grep -zv 'fixup!'
139+
- name: Disallow squash commits
140+
run: git log --pretty=format:%s origin/main..HEAD | grep -zv 'squash!'
141+
- name: Disallow edit commits
142+
run: git log --pretty=format:%s origin/main..HEAD | grep -zv 'edit!'
143+
- name: Disallow drop commits
144+
run: git log --pretty=format:%s origin/main..HEAD | grep -zv 'drop!'

0 commit comments

Comments
 (0)