Skip to content

Commit 3d0d663

Browse files
committed
feat: support option #85
1 parent 92872c1 commit 3d0d663

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

.commit-check.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@ checks:
2323
regex: ^.+@.+$
2424
error: The committer email seems invalid
2525
suggest: run command `git config user.email yourname@example.com`
26+
27+
- check: merge_base
28+
regex: main # it can be master, develop, devel etc based on your project.
29+
error: Current branch is not rebased onto target branch
30+
suggest: please ensure your branch is rebased with the target branch

.github/workflows/commit-check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ jobs:
2424
author-name: true
2525
author-email: true
2626
commit-signoff: true
27+
merge-base: true
2728
job-summary: true
2829
pr-comments: ${{ github.event_name == 'pull_request' }}

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
author-name: true
4040
author-email: true
4141
commit-signoff: true
42+
merge-base: false
4243
job-summary: true
4344
pr-comments: ${{ github.event_name == 'pull_request' }}
4445
```
@@ -59,38 +60,46 @@ jobs:
5960

6061
### `author-name`
6162

62-
- **Description**: check committer author name
63+
- **Description**: check committer author name.
6364
- Default: 'true'
6465

6566
### `author-email`
6667

67-
- **Description**: check committer author email
68+
- **Description**: check committer author email.
6869
- Default: 'true'
6970

7071
### `commit-signoff`
7172

72-
- **Description**: check committer commit signature
73+
- **Description**: check committer commit signature.
7374
- Default: 'true'
7475

76+
### `merge-base`
77+
78+
- **Description**: check current branch is rebased onto target branch.
79+
- Default: 'false'
80+
81+
> [!IMPORTANT]
82+
> `merge-base` is an experimental feature. by default it's disable.
83+
7584
### `dry-run`
7685

7786
- **Description**: run checks without failing. exit code is 0 otherwise is 1.
7887
- Default: 'false'
7988

8089
### `job-summary`
8190

82-
- **Description**: display job summary to the workflow run
91+
- **Description**: display job summary to the workflow run.
8392
- Default: 'true'
8493

8594
### `pr-comments`
8695

87-
- **Description**: post results to the pull request comments
96+
- **Description**: post results to the pull request comments.
8897
- Default: 'false'
8998

9099
> [!IMPORTANT]
91-
> `pr-comments` is an experimental feature. To use it you need to set `GITHUB_TOKEN` in the GitHub Action.
100+
> `pr-comments` is an experimental feature. by default it's disable. To use it you need to set `GITHUB_TOKEN` in the GitHub Action.
92101
>
93-
> This feature currently doesn’t work with forked repositories. For more details, refer to issue [#77](https://github.com/commit-check/commit-check-action/issues/77)
102+
> This feature currently doesn’t work with forked repositories. For more details, refer to issue [#77](https://github.com/commit-check/commit-check-action/issues/77).
94103

95104
Note: the default rule of above inputs is following [this configuration](https://github.com/commit-check/commit-check/blob/main/.commit-check.yml), if you want to customize just add your `.commit-check.yml` config file under your repository root directory.
96105

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ inputs:
2525
description: check committer commit signature
2626
required: false
2727
default: true
28+
merge-base:
29+
description: check current branch is rebased onto target branch
30+
required: false
31+
default: false
2832
dry-run:
2933
description: run checks without failing
3034
required: false

main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
AUTHOR_NAME = os.getenv("AUTHOR_NAME", "false")
1717
AUTHOR_EMAIL = os.getenv("AUTHOR_EMAIL", "false")
1818
COMMIT_SIGNOFF = os.getenv("COMMIT_SIGNOFF", "false")
19+
MERGE_BASE = os.getenv("MERGE_BASE", "false")
1920
DRY_RUN = os.getenv("DRY_RUN", "false")
2021
JOB_SUMMARY = os.getenv("JOB_SUMMARY", "false")
2122
PR_COMMENTS = os.getenv("PR_COMMENTS", "false")
@@ -32,6 +33,7 @@ def log_env_vars():
3233
print(f"AUTHOR_NAME = {AUTHOR_NAME}")
3334
print(f"AUTHOR_EMAIL = {AUTHOR_EMAIL}")
3435
print(f"COMMIT_SIGNOFF = {COMMIT_SIGNOFF}")
36+
print(f"MERGE_BASE = {MERGE_BASE}")
3537
print(f"DRY_RUN = {DRY_RUN}")
3638
print(f"JOB_SUMMARY = {JOB_SUMMARY}")
3739
print(f"PR_COMMENTS = {PR_COMMENTS}\n")
@@ -45,11 +47,12 @@ def run_commit_check() -> int:
4547
"--author-name",
4648
"--author-email",
4749
"--commit-signoff",
50+
"--merge-base",
4851
]
4952
args = [
5053
arg
5154
for arg, value in zip(
52-
args, [MESSAGE, BRANCH, AUTHOR_NAME, AUTHOR_EMAIL, COMMIT_SIGNOFF]
55+
args, [MESSAGE, BRANCH, AUTHOR_NAME, AUTHOR_EMAIL, COMMIT_SIGNOFF, MERGE_BASE]
5356
)
5457
if value == "true"
5558
]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy