commit-shield 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- commit_shield-0.2.0/.commit-guard.toml.example +84 -0
- commit_shield-0.2.0/.github/ISSUE_TEMPLATE/bug_report.yml +39 -0
- commit_shield-0.2.0/.github/ISSUE_TEMPLATE/feature_request.yml +27 -0
- commit_shield-0.2.0/.github/PULL_REQUEST_TEMPLATE.md +17 -0
- commit_shield-0.2.0/.github/workflows/ci.yml +101 -0
- commit_shield-0.2.0/.github/workflows/release.yml +30 -0
- commit_shield-0.2.0/.gitignore +26 -0
- commit_shield-0.2.0/.pre-commit-hooks.yaml +14 -0
- commit_shield-0.2.0/CHANGELOG.md +89 -0
- commit_shield-0.2.0/CODE_OF_CONDUCT.md +114 -0
- commit_shield-0.2.0/CONTRIBUTING.md +38 -0
- commit_shield-0.2.0/LICENSE +21 -0
- commit_shield-0.2.0/PKG-INFO +179 -0
- commit_shield-0.2.0/README.md +147 -0
- commit_shield-0.2.0/commit_guard/__init__.py +5 -0
- commit_shield-0.2.0/commit_guard/_toml.py +276 -0
- commit_shield-0.2.0/commit_guard/checkers.py +277 -0
- commit_shield-0.2.0/commit_guard/cli.py +401 -0
- commit_shield-0.2.0/commit_guard/config.py +340 -0
- commit_shield-0.2.0/commit_guard/gitutil.py +106 -0
- commit_shield-0.2.0/pyproject.toml +87 -0
- commit_shield-0.2.0/tests/test_checkers.py +87 -0
- commit_shield-0.2.0/tests/test_cli.py +306 -0
- commit_shield-0.2.0/tests/test_config.py +263 -0
- commit_shield-0.2.0/tests/test_toml.py +119 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# commit-guard configuration.
|
|
2
|
+
#
|
|
3
|
+
# Copy this file to `.commit-guard.toml` in your repository root, or move the
|
|
4
|
+
# settings under a `[tool.commit-guard]` table in your `pyproject.toml`.
|
|
5
|
+
#
|
|
6
|
+
# Precedence, lowest to highest:
|
|
7
|
+
# built-in defaults < pyproject.toml < .commit-guard.toml < CLI flags
|
|
8
|
+
#
|
|
9
|
+
# Discovery walks upward from the current directory to the repository root, so
|
|
10
|
+
# a package inside a monorepo can override the rules set at the top level.
|
|
11
|
+
# Every setting below is optional; the value shown is the default.
|
|
12
|
+
|
|
13
|
+
# ---------------------------------------------------------------------------
|
|
14
|
+
# Commit message rules
|
|
15
|
+
# ---------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
# Allowed commit types. Replaces the default list entirely.
|
|
18
|
+
types = [
|
|
19
|
+
"feat", "fix", "docs", "style", "refactor",
|
|
20
|
+
"perf", "test", "build", "ci", "chore", "revert",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
# Allowed scopes, as in `feat(api): ...`. An empty list allows any scope.
|
|
24
|
+
scopes = []
|
|
25
|
+
|
|
26
|
+
# Require every commit to carry a scope. Setting this to true with an empty
|
|
27
|
+
# `scopes` list is rejected, since it would reject every possible commit.
|
|
28
|
+
require_scope = false
|
|
29
|
+
|
|
30
|
+
# Maximum length of the header (the first line).
|
|
31
|
+
max_header_len = 72
|
|
32
|
+
|
|
33
|
+
# Minimum length of the subject, i.e. the text after `type(scope):`.
|
|
34
|
+
subject_min_len = 3
|
|
35
|
+
|
|
36
|
+
# Allow the subject to end with a period.
|
|
37
|
+
allow_trailing_period = false
|
|
38
|
+
|
|
39
|
+
# Maximum length of a body line. 0 disables the check. URLs, git trailers
|
|
40
|
+
# (`Co-Authored-By:`), and indented or quoted lines are always exempt, since
|
|
41
|
+
# those cannot be wrapped without breaking them.
|
|
42
|
+
max_body_line_len = 0
|
|
43
|
+
|
|
44
|
+
# Skip validation for messages git writes itself: merges, reverts, and the
|
|
45
|
+
# fixup!/squash! markers used by interactive rebase.
|
|
46
|
+
skip_merge_commits = true
|
|
47
|
+
skip_prefixes = ["merge ", "revert ", "fixup!", "squash!", "amend!"]
|
|
48
|
+
|
|
49
|
+
# ---------------------------------------------------------------------------
|
|
50
|
+
# Staged file rules
|
|
51
|
+
# ---------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
# Maximum staged blob size, in megabytes.
|
|
54
|
+
max_size_mb = 10.0
|
|
55
|
+
|
|
56
|
+
# Paths matching any of these regexes are reported as sensitive. Setting this
|
|
57
|
+
# key REPLACES the built-in list; to keep the defaults and add to them, use
|
|
58
|
+
# `extra_sensitive_patterns` below instead.
|
|
59
|
+
#
|
|
60
|
+
# sensitive_patterns = [
|
|
61
|
+
# "(^|/)\.env($|\..*)",
|
|
62
|
+
# "(^|/).*\.(pem|pkcs12|pfx|p12|jks|keystore)$",
|
|
63
|
+
# "(^|/)id_(rsa|dsa|ed25519|ecdsa)($|\..*)",
|
|
64
|
+
# "(^|/).*(secret|password|credential)s?.*\.(json|ya?ml|txt|ini|cfg)$",
|
|
65
|
+
# "(^|/)\.(npmrc|pypirc|netrc)$",
|
|
66
|
+
# "(^|/)\.aws/credentials$",
|
|
67
|
+
# "(^|/).*\.key$",
|
|
68
|
+
# ]
|
|
69
|
+
|
|
70
|
+
# Patterns APPENDED to the built-in list. This is usually what you want.
|
|
71
|
+
extra_sensitive_patterns = []
|
|
72
|
+
|
|
73
|
+
# Paths that look sensitive but are safe to commit. Matched with shell-style
|
|
74
|
+
# globs against both the full path and the file name; an entry ending in `/`
|
|
75
|
+
# exempts a whole directory.
|
|
76
|
+
allowlist = [
|
|
77
|
+
"*.example",
|
|
78
|
+
"*.sample",
|
|
79
|
+
"*.template",
|
|
80
|
+
"*.dist",
|
|
81
|
+
".env.example",
|
|
82
|
+
".env.sample",
|
|
83
|
+
".env.template",
|
|
84
|
+
]
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: "🐛 Bug Report"
|
|
2
|
+
description: File a bug report to help us improve commit-guard.
|
|
3
|
+
labels: ["bug"]
|
|
4
|
+
body:
|
|
5
|
+
- type: markdown
|
|
6
|
+
attributes:
|
|
7
|
+
value: |
|
|
8
|
+
Thanks for taking the time to report an issue!
|
|
9
|
+
- type: textarea
|
|
10
|
+
id: description
|
|
11
|
+
attributes:
|
|
12
|
+
label: Bug Description
|
|
13
|
+
description: A clear and concise description of what the bug is.
|
|
14
|
+
validations:
|
|
15
|
+
required: true
|
|
16
|
+
- type: textarea
|
|
17
|
+
id: reproduction
|
|
18
|
+
attributes:
|
|
19
|
+
label: Steps to Reproduce
|
|
20
|
+
description: Steps to reproduce the behavior.
|
|
21
|
+
placeholder: |
|
|
22
|
+
1. Run command 'commit-guard check ...'
|
|
23
|
+
2. With config '...'
|
|
24
|
+
3. See error
|
|
25
|
+
validations:
|
|
26
|
+
required: true
|
|
27
|
+
- type: textarea
|
|
28
|
+
id: expected
|
|
29
|
+
attributes:
|
|
30
|
+
label: Expected Behavior
|
|
31
|
+
description: What did you expect to happen?
|
|
32
|
+
validations:
|
|
33
|
+
required: true
|
|
34
|
+
- type: input
|
|
35
|
+
id: environment
|
|
36
|
+
attributes:
|
|
37
|
+
label: Environment
|
|
38
|
+
description: OS version, Python version, commit-guard version
|
|
39
|
+
placeholder: Ubuntu 24.04 / macOS Sonoma / Windows 11, Python 3.12, commit-guard v0.2.0
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: "💡 Feature Request"
|
|
2
|
+
description: Suggest an idea or feature enhancement for commit-guard.
|
|
3
|
+
labels: ["enhancement"]
|
|
4
|
+
body:
|
|
5
|
+
- type: markdown
|
|
6
|
+
attributes:
|
|
7
|
+
value: |
|
|
8
|
+
We welcome feature requests and ideas from the community!
|
|
9
|
+
- type: textarea
|
|
10
|
+
id: problem
|
|
11
|
+
attributes:
|
|
12
|
+
label: Problem / Motivation
|
|
13
|
+
description: Is your feature request related to a problem or limitation?
|
|
14
|
+
validations:
|
|
15
|
+
required: true
|
|
16
|
+
- type: textarea
|
|
17
|
+
id: solution
|
|
18
|
+
attributes:
|
|
19
|
+
label: Proposed Solution
|
|
20
|
+
description: A clear and concise description of what you want to happen.
|
|
21
|
+
validations:
|
|
22
|
+
required: true
|
|
23
|
+
- type: textarea
|
|
24
|
+
id: alternatives
|
|
25
|
+
attributes:
|
|
26
|
+
label: Alternatives Considered
|
|
27
|
+
description: Any alternative solutions or features you've considered.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
## Description
|
|
2
|
+
<!-- Briefly describe what this PR does, why it is needed, and link any related issues. -->
|
|
3
|
+
Fixes #
|
|
4
|
+
|
|
5
|
+
## Type of Change
|
|
6
|
+
- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
|
|
7
|
+
- [ ] ✨ New feature (non-breaking change which adds functionality)
|
|
8
|
+
- [ ] 📝 Documentation update
|
|
9
|
+
- [ ] 🧪 Tests / CI improvement
|
|
10
|
+
- [ ] ⚡ Performance improvement
|
|
11
|
+
|
|
12
|
+
## Checklist
|
|
13
|
+
- [ ] My code adheres to the project's zero-external-dependency rule for runtime code.
|
|
14
|
+
- [ ] I have added unit tests that prove my fix is effective or that my feature works.
|
|
15
|
+
- [ ] All tests pass locally with `python -m unittest discover -s tests`.
|
|
16
|
+
- [ ] Code is formatted and typed properly.
|
|
17
|
+
- [ ] I have updated relevant documentation if applicable.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
name: Tests (${{ matrix.python-version }} on ${{ matrix.os }})
|
|
12
|
+
runs-on: ${{ matrix.os }}
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
os: [ubuntu-latest]
|
|
17
|
+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
18
|
+
include:
|
|
19
|
+
# setup-python no longer ships 3.8 for ubuntu-latest (24.04), so the
|
|
20
|
+
# oldest supported interpreter is pinned to 22.04.
|
|
21
|
+
- os: ubuntu-22.04
|
|
22
|
+
python-version: "3.8"
|
|
23
|
+
# commit-guard writes git hooks and manipulates paths, so Windows is
|
|
24
|
+
# exercised at both ends of the supported range.
|
|
25
|
+
- os: windows-latest
|
|
26
|
+
python-version: "3.8"
|
|
27
|
+
- os: windows-latest
|
|
28
|
+
python-version: "3.13"
|
|
29
|
+
- os: macos-latest
|
|
30
|
+
python-version: "3.13"
|
|
31
|
+
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/checkout@v4
|
|
34
|
+
|
|
35
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
36
|
+
uses: actions/setup-python@v5
|
|
37
|
+
with:
|
|
38
|
+
python-version: ${{ matrix.python-version }}
|
|
39
|
+
|
|
40
|
+
- name: Configure git identity
|
|
41
|
+
# The hook tests initialise throwaway repositories.
|
|
42
|
+
run: |
|
|
43
|
+
git config --global user.email "ci@example.com"
|
|
44
|
+
git config --global user.name "CI"
|
|
45
|
+
git config --global init.defaultBranch main
|
|
46
|
+
|
|
47
|
+
- name: Run unit tests (built-in unittest)
|
|
48
|
+
run: python -m unittest discover tests -v
|
|
49
|
+
|
|
50
|
+
- name: Test CLI execution
|
|
51
|
+
run: |
|
|
52
|
+
pip install .
|
|
53
|
+
commit-guard --version
|
|
54
|
+
commit-guard check-msg -m "feat(ci): test github actions workflow"
|
|
55
|
+
|
|
56
|
+
lint:
|
|
57
|
+
name: Lint and type-check
|
|
58
|
+
runs-on: ubuntu-latest
|
|
59
|
+
# Separate job on purpose: ruff and mypy are development tools only. They
|
|
60
|
+
# are installed here and never become runtime dependencies of the package.
|
|
61
|
+
steps:
|
|
62
|
+
- uses: actions/checkout@v4
|
|
63
|
+
|
|
64
|
+
- name: Set up Python
|
|
65
|
+
uses: actions/setup-python@v5
|
|
66
|
+
with:
|
|
67
|
+
python-version: "3.12"
|
|
68
|
+
|
|
69
|
+
- name: Install lint tooling
|
|
70
|
+
run: pip install "ruff==0.6.9" "mypy==1.11.2"
|
|
71
|
+
|
|
72
|
+
- name: Ruff (lint)
|
|
73
|
+
run: ruff check commit_guard tests
|
|
74
|
+
|
|
75
|
+
- name: Ruff (format check)
|
|
76
|
+
run: ruff format --check commit_guard tests
|
|
77
|
+
|
|
78
|
+
- name: Mypy
|
|
79
|
+
run: mypy commit_guard
|
|
80
|
+
|
|
81
|
+
package:
|
|
82
|
+
name: Verify package builds
|
|
83
|
+
runs-on: ubuntu-latest
|
|
84
|
+
steps:
|
|
85
|
+
- uses: actions/checkout@v4
|
|
86
|
+
|
|
87
|
+
- name: Set up Python
|
|
88
|
+
uses: actions/setup-python@v5
|
|
89
|
+
with:
|
|
90
|
+
python-version: "3.12"
|
|
91
|
+
|
|
92
|
+
- name: Build sdist and wheel
|
|
93
|
+
run: |
|
|
94
|
+
pip install build
|
|
95
|
+
python -m build
|
|
96
|
+
|
|
97
|
+
- name: Check that the dynamic version resolves
|
|
98
|
+
# Guards against __version__ and the packaging metadata drifting apart.
|
|
99
|
+
run: |
|
|
100
|
+
pip install dist/*.whl
|
|
101
|
+
test "$(commit-guard --version)" = "commit-guard $(python -c 'import commit_guard; print(commit_guard.__version__)')"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
pypi-publish:
|
|
9
|
+
name: Build and upload to PyPI
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
id-token: write
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Python
|
|
19
|
+
uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.12"
|
|
22
|
+
|
|
23
|
+
- name: Install build tool
|
|
24
|
+
run: pip install build
|
|
25
|
+
|
|
26
|
+
- name: Build sdist and wheel
|
|
27
|
+
run: python -m build
|
|
28
|
+
|
|
29
|
+
- name: Publish package to PyPI
|
|
30
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*$py.class
|
|
4
|
+
*.so
|
|
5
|
+
.Python
|
|
6
|
+
build/
|
|
7
|
+
develop-eggs/
|
|
8
|
+
dist/
|
|
9
|
+
downloads/
|
|
10
|
+
eggs/
|
|
11
|
+
.eggs/
|
|
12
|
+
lib/
|
|
13
|
+
lib64/
|
|
14
|
+
parts/
|
|
15
|
+
sdist/
|
|
16
|
+
var/
|
|
17
|
+
wheels/
|
|
18
|
+
*.egg-info/
|
|
19
|
+
.installed.cfg
|
|
20
|
+
*.egg
|
|
21
|
+
.venv
|
|
22
|
+
venv/
|
|
23
|
+
ENV/
|
|
24
|
+
.env
|
|
25
|
+
.pytest_cache/
|
|
26
|
+
.ruff_cache/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
- id: commit-guard-msg
|
|
2
|
+
name: commit-guard-msg
|
|
3
|
+
description: Validate commit message against Conventional Commits standard
|
|
4
|
+
entry: commit-guard check-msg
|
|
5
|
+
language: python
|
|
6
|
+
stages: [commit-msg]
|
|
7
|
+
always_run: true
|
|
8
|
+
|
|
9
|
+
- id: commit-guard-files
|
|
10
|
+
name: commit-guard-files
|
|
11
|
+
description: Validate staged files for size and sensitive patterns
|
|
12
|
+
entry: commit-guard check-files --strict
|
|
13
|
+
language: python
|
|
14
|
+
stages: [pre-commit]
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.2.0] - 2026-09-18
|
|
9
|
+
|
|
10
|
+
The theme of this release is correctness and configurability. v0.1.0 validated
|
|
11
|
+
the happy path; this release fixes the cases where it was wrong, and lets you
|
|
12
|
+
change the rules without editing the source.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **Configuration files.** Settings are read from `[tool.commit-guard]` in
|
|
17
|
+
`pyproject.toml` or from a standalone `.commit-guard.toml`. Discovery walks
|
|
18
|
+
upward from the current directory to the repository root, so a monorepo can
|
|
19
|
+
override rules per package. Precedence is: built-in defaults, then
|
|
20
|
+
`pyproject.toml`, then `.commit-guard.toml`, then CLI flags.
|
|
21
|
+
- `--config PATH` to name a configuration file explicitly (disables discovery),
|
|
22
|
+
and `--no-config` to ignore configuration files entirely.
|
|
23
|
+
- `-q` / `--quiet` on the validating subcommands, to suppress success output
|
|
24
|
+
while still reporting failures.
|
|
25
|
+
- **`uninstall` subcommand**, which removes only hooks commit-guard installed
|
|
26
|
+
and restores any hook it previously backed up.
|
|
27
|
+
- `install --force` to replace a hook owned by another tool, keeping the
|
|
28
|
+
original as `<hook>.bak`, and `install --msg-only` to skip the `pre-commit`
|
|
29
|
+
hook.
|
|
30
|
+
- `install` now installs a `pre-commit` hook (`check-files --strict`) in
|
|
31
|
+
addition to `commit-msg`.
|
|
32
|
+
- An allowlist for paths that look sensitive but are not: `*.example`,
|
|
33
|
+
`*.sample`, `*.template`, `*.dist` and friends are no longer flagged.
|
|
34
|
+
- Configurable `scopes` with `require_scope`, `subject_min_len`,
|
|
35
|
+
`allow_trailing_period`, and an optional `max_body_line_len` body check that
|
|
36
|
+
exempts URLs, git trailers and indented or quoted lines.
|
|
37
|
+
- An example `.commit-guard.toml.example` documenting every setting.
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
|
|
41
|
+
- **Merge, revert, fixup and squash commits no longer fail validation.** Git
|
|
42
|
+
generates these messages itself, so rejecting them made `git merge` and
|
|
43
|
+
interactive rebase unusable. Controlled by `skip_merge_commits` and
|
|
44
|
+
`skip_prefixes`.
|
|
45
|
+
- **`install` no longer destroys an existing hook.** It now refuses to
|
|
46
|
+
overwrite a hook it does not own, names the framework that owns it
|
|
47
|
+
(pre-commit, husky, lefthook) in the message, and only replaces it with
|
|
48
|
+
`--force`, keeping a `.bak` copy.
|
|
49
|
+
- **Git failures are no longer treated as "nothing to check".** v0.1.0 caught
|
|
50
|
+
every exception around git and returned success, so a broken repository or a
|
|
51
|
+
missing `git` silently passed the commit. Git errors now exit with code 2.
|
|
52
|
+
- **File size is read from the staged blob, not the working tree.** Checking
|
|
53
|
+
the file on disk reported the wrong size whenever the working copy had moved
|
|
54
|
+
on from what was staged.
|
|
55
|
+
- **Installed hooks call `sys.executable`, not a bare `python`.** The old hook
|
|
56
|
+
broke wherever the interpreter commit-guard was installed into was not first
|
|
57
|
+
on `PATH`, or was not named `python`.
|
|
58
|
+
- `__version__` and the packaging metadata can no longer drift: the version is
|
|
59
|
+
single-sourced from `commit_guard/__init__.py` via Hatch.
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
|
|
63
|
+
- **Exit code 2 now means "commit-guard could not do its job"**, as distinct
|
|
64
|
+
from exit code 1, "the commit is invalid". Exit code 0 still means success.
|
|
65
|
+
Scripts that only branch on zero/non-zero are unaffected.
|
|
66
|
+
- Unknown keys in a configuration file are an error rather than a silent
|
|
67
|
+
no-op, so a typo such as `max_header_length` is reported instead of ignored.
|
|
68
|
+
- An uppercase type (`Feat: ...`) now reports "type must be lowercase" instead
|
|
69
|
+
of the generic format error.
|
|
70
|
+
|
|
71
|
+
### Compatibility
|
|
72
|
+
|
|
73
|
+
- Public API from v0.1.0 is unchanged: `check_commit_message(msg,
|
|
74
|
+
max_header_len=...)` and `check_file_path(path, max_size_mb=...)` keep their
|
|
75
|
+
signatures, and `CONVENTIONAL_TYPES` is still exported. Both functions take
|
|
76
|
+
a new optional `config=` argument.
|
|
77
|
+
- Still zero runtime dependencies, still `requires-python >= 3.8`. TOML is read
|
|
78
|
+
with `tomllib` on 3.11+ and with a small bundled parser below that.
|
|
79
|
+
|
|
80
|
+
## [0.1.0] - 2026-09-17
|
|
81
|
+
|
|
82
|
+
### Added
|
|
83
|
+
|
|
84
|
+
- Initial release: Conventional Commits validation, detection of sensitive
|
|
85
|
+
staged files and oversized blobs, a `commit-msg` hook installer, and
|
|
86
|
+
`pre-commit` framework integration.
|
|
87
|
+
|
|
88
|
+
[0.2.0]: https://github.com/lui01212/commit-guard/releases/tag/v0.2.0
|
|
89
|
+
[0.1.0]: https://github.com/lui01212/commit-guard/releases/tag/v0.1.0
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
+
identity and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the
|
|
26
|
+
overall community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
+
any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email
|
|
35
|
+
address, without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
luynbv@glotechvn.com.
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
76
|
+
unprofessional or unwelcome in the community.
|
|
77
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
78
|
+
clarity around the nature of the violation and an explanation of why the
|
|
79
|
+
behavior was inappropriate. A public apology may be requested.
|
|
80
|
+
|
|
81
|
+
### 2. Warning
|
|
82
|
+
**Community Impact**: A violation through a single incident or series of
|
|
83
|
+
actions.
|
|
84
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
85
|
+
interaction with the people involved, including unsolicited interaction with
|
|
86
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
87
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
88
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
|
89
|
+
ban.
|
|
90
|
+
|
|
91
|
+
### 3. Temporary Ban
|
|
92
|
+
**Community Impact**: A serious violation of community standards, including
|
|
93
|
+
sustained inappropriate behavior.
|
|
94
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
95
|
+
communication with the community for a specified period of time. No public or
|
|
96
|
+
private interaction with the people involved, including unsolicited interaction
|
|
97
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
98
|
+
Violating these terms may lead to a permanent ban.
|
|
99
|
+
|
|
100
|
+
### 4. Permanent Ban
|
|
101
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
102
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
103
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
104
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
|
105
|
+
community.
|
|
106
|
+
|
|
107
|
+
## Attribution
|
|
108
|
+
|
|
109
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
110
|
+
version 2.1, available at
|
|
111
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
112
|
+
|
|
113
|
+
[homepage]: https://www.contributor-covenant.org
|
|
114
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Contributing to commit-guard
|
|
2
|
+
|
|
3
|
+
Welcome! We are excited to have you contribute to **commit-guard**.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🌟 Good First Issues
|
|
8
|
+
|
|
9
|
+
Looking for your first contribution? Check our [open issues with label `good first issue`](https://github.com/lui01212/commit-guard/issues?q=is%3Aissue+state%3Aopen+label%3A%22good+first+issue%22). Common beginner tasks include:
|
|
10
|
+
- Adding new sensitive file patterns to `commit_guard/checkers.py`.
|
|
11
|
+
- Adding unit test cases for edge-case commit messages.
|
|
12
|
+
- Improving documentation or translation of error messages.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 🛠️ Development Setup
|
|
17
|
+
|
|
18
|
+
1. **Fork and clone:**
|
|
19
|
+
```bash
|
|
20
|
+
git clone https://github.com/<your-username>/commit-guard.git
|
|
21
|
+
cd commit-guard
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
2. **Zero-dependency philosophy:**
|
|
25
|
+
This project relies exclusively on Python standard libraries! No heavy third-party packages are required.
|
|
26
|
+
|
|
27
|
+
3. **Running tests:**
|
|
28
|
+
Run the test suite using Python's built-in `unittest`:
|
|
29
|
+
```bash
|
|
30
|
+
python -m unittest discover tests
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
4. **Making changes:**
|
|
34
|
+
- Create a branch: `git checkout -b feature/your-feature-name`
|
|
35
|
+
- Write tests for your changes in `tests/test_checkers.py`.
|
|
36
|
+
- Run tests to ensure everything passes: `python -m unittest`
|
|
37
|
+
- Commit with Conventional Commits: `git commit -m "feat(checker): add regex check for api keys"`
|
|
38
|
+
- Push and open a Pull Request!
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 lui01212
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|