Skip to content

feat: add imperative mood #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/commit-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ jobs:
author-email: true
commit-signoff: true
merge-base: true
imperative: true
job-summary: true
pr-comments: ${{ github.event_name == 'pull_request' }}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
author-email: true
commit-signoff: true
merge-base: false
imperative: true
job-summary: true
pr-comments: ${{ github.event_name == 'pull_request' }}
```
Expand Down Expand Up @@ -114,6 +115,11 @@ jobs:
>
> To use this feature, you need fetch all history for all branches by setting `fetch-depth: 0` in `actions/checkout`.

### `imperative`

- **Description**: check commit message is imperative mood.
- Default: `true`

### `dry-run`

- **Description**: run checks without failing. exit code is 0 otherwise is 1.
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ inputs:
description: check current branch is rebased onto target branch
required: false
default: false
imperative:
description: check commit message is in imperative mood
required: false
default: true
dry-run:
description: run checks without failing
required: false
Expand Down Expand Up @@ -76,6 +80,7 @@ runs:
AUTHOR_EMAIL: ${{ inputs.author-email }}
COMMIT_SIGNOFF: ${{ inputs.commit-signoff }}
MERGE_BASE: ${{ inputs.merge-base }}
IMPERATIVE: ${{ inputs.imperative }}
DRY_RUN: ${{ inputs.dry-run }}
JOB_SUMMARY: ${{ inputs.job-summary }}
PR_COMMENTS: ${{ inputs.pr-comments }}
13 changes: 12 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
AUTHOR_EMAIL = os.getenv("AUTHOR_EMAIL", "false")
COMMIT_SIGNOFF = os.getenv("COMMIT_SIGNOFF", "false")
MERGE_BASE = os.getenv("MERGE_BASE", "false")
IMPERATIVE = os.getenv("IMPERATIVE", "true")
DRY_RUN = os.getenv("DRY_RUN", "false")
JOB_SUMMARY = os.getenv("JOB_SUMMARY", "false")
PR_COMMENTS = os.getenv("PR_COMMENTS", "false")
Expand All @@ -34,6 +35,7 @@ def log_env_vars():
print(f"AUTHOR_EMAIL = {AUTHOR_EMAIL}")
print(f"COMMIT_SIGNOFF = {COMMIT_SIGNOFF}")
print(f"MERGE_BASE = {MERGE_BASE}")
print(f"IMPERATIVE = {IMPERATIVE}")
print(f"DRY_RUN = {DRY_RUN}")
print(f"JOB_SUMMARY = {JOB_SUMMARY}")
print(f"PR_COMMENTS = {PR_COMMENTS}\n")
Expand All @@ -48,12 +50,21 @@ def run_commit_check() -> int:
"--author-email",
"--commit-signoff",
"--merge-base",
"--imperative",
]
args = [
arg
for arg, value in zip(
args,
[MESSAGE, BRANCH, AUTHOR_NAME, AUTHOR_EMAIL, COMMIT_SIGNOFF, MERGE_BASE],
[
MESSAGE,
BRANCH,
AUTHOR_NAME,
AUTHOR_EMAIL,
COMMIT_SIGNOFF,
MERGE_BASE,
IMPERATIVE,
],
)
if value == "true"
]
Expand Down