cleanmsg 0.1.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.
- cleanmsg-0.1.0/.github/workflows/ci.yml +24 -0
- cleanmsg-0.1.0/.github/workflows/release.yml +23 -0
- cleanmsg-0.1.0/.gitignore +7 -0
- cleanmsg-0.1.0/LICENSE +21 -0
- cleanmsg-0.1.0/PKG-INFO +214 -0
- cleanmsg-0.1.0/README.md +192 -0
- cleanmsg-0.1.0/bin/cleanmsg +9 -0
- cleanmsg-0.1.0/pyproject.toml +45 -0
- cleanmsg-0.1.0/src/cleanmsg/__init__.py +3 -0
- cleanmsg-0.1.0/src/cleanmsg/__main__.py +3 -0
- cleanmsg-0.1.0/src/cleanmsg/clean.py +151 -0
- cleanmsg-0.1.0/src/cleanmsg/cli.py +266 -0
- cleanmsg-0.1.0/src/cleanmsg/github.py +77 -0
- cleanmsg-0.1.0/src/cleanmsg/gitops.py +342 -0
- cleanmsg-0.1.0/tests/test_clean.py +109 -0
- cleanmsg-0.1.0/tests/test_e2e.py +188 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
strategy:
|
|
11
|
+
fail-fast: false
|
|
12
|
+
matrix:
|
|
13
|
+
os: [ubuntu-latest, macos-latest]
|
|
14
|
+
python: ["3.10", "3.14"]
|
|
15
|
+
runs-on: ${{ matrix.os }}
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v5
|
|
18
|
+
- uses: actions/setup-python@v6
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python }}
|
|
21
|
+
- name: Install test tools (pytest + git-filter-repo, so both engines are tested)
|
|
22
|
+
run: python -m pip install pytest git-filter-repo
|
|
23
|
+
- name: Run tests
|
|
24
|
+
run: python -m pytest -v
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Publishes to PyPI when a version tag (v1.2.3) is pushed.
|
|
2
|
+
# One-time setup: on pypi.org add a "trusted publisher" for this repo
|
|
3
|
+
# with workflow name "release.yml" and environment "pypi".
|
|
4
|
+
name: Release
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
tags: ["v*"]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
publish:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
environment: pypi
|
|
14
|
+
permissions:
|
|
15
|
+
id-token: write
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v5
|
|
18
|
+
- uses: actions/setup-python@v6
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.13"
|
|
21
|
+
- run: python -m pip install build
|
|
22
|
+
- run: python -m build
|
|
23
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
cleanmsg-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 enikakis
|
|
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.
|
cleanmsg-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: cleanmsg
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Remove AI attribution lines (Co-Authored-By: Claude, Copilot, Cursor...) or any text from git commit messages, safely.
|
|
5
|
+
Project-URL: Homepage, https://github.com/enikakis/cleanmsg
|
|
6
|
+
Project-URL: Issues, https://github.com/enikakis/cleanmsg/issues
|
|
7
|
+
Author: enikakis
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: ai,claude,cli,co-authored-by,commit-message,copilot,git,rewrite-history
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Provides-Extra: fast
|
|
20
|
+
Requires-Dist: git-filter-repo; extra == 'fast'
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# cleanmsg
|
|
24
|
+
|
|
25
|
+
**Remove AI attribution lines, or any text, from your git commit messages. Safely.**
|
|
26
|
+
|
|
27
|
+
AI coding tools like to sign their work. After a while your history looks like this:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
Add login form
|
|
31
|
+
|
|
32
|
+
🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
33
|
+
|
|
34
|
+
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Whether you keep those lines is your call (some projects require them). If you
|
|
38
|
+
don't want them, `cleanmsg` strips them out of existing commits: it shows you what
|
|
39
|
+
will change first, keeps a backup, and can force-push the result to GitHub.
|
|
40
|
+
|
|
41
|
+
It works for any text, too: `WIP`, `[skip ci]`, a ticket number, a typo you
|
|
42
|
+
repeated in 40 commits.
|
|
43
|
+
|
|
44
|
+
## Example
|
|
45
|
+
|
|
46
|
+
```console
|
|
47
|
+
$ cleanmsg --ai
|
|
48
|
+
3 commit message(s) to change in branch 'main':
|
|
49
|
+
88912d10 Add password reset flow
|
|
50
|
+
- 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
51
|
+
- Co-Authored-By: Claude <noreply@anthropic.com>
|
|
52
|
+
d4de968e Validate e-mail on submit
|
|
53
|
+
- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
|
54
|
+
52744c5d Add login form
|
|
55
|
+
- 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
56
|
+
- Co-Authored-By: Claude <noreply@anthropic.com>
|
|
57
|
+
|
|
58
|
+
Preview only, nothing changed. Add --apply to rewrite (and --push to update GitHub).
|
|
59
|
+
|
|
60
|
+
$ cleanmsg --ai --apply --push
|
|
61
|
+
...
|
|
62
|
+
Rewrite and force-push branch 'main'? [y/N] y
|
|
63
|
+
Rewriting with git filter-repo...
|
|
64
|
+
Done. Backup saved as 20261127-135715 (undo with: cleanmsg --undo)
|
|
65
|
+
Force-pushing main -> origin/main
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Afterwards the commit reads just:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
Add login form
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Removing your own text works the same way:
|
|
75
|
+
|
|
76
|
+
```console
|
|
77
|
+
$ cleanmsg "my change"
|
|
78
|
+
1 commit message(s) to change in branch 'main':
|
|
79
|
+
169560e2 fix login my change
|
|
80
|
+
- fix login my change
|
|
81
|
+
+ fix login
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Install
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pipx install "cleanmsg[fast]" # or: uv tool install "cleanmsg[fast]"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`[fast]` also installs [git-filter-repo](https://github.com/newren/git-filter-repo),
|
|
91
|
+
which makes rewriting large repos much faster. Without it, `cleanmsg` falls back to
|
|
92
|
+
the `git filter-branch` command that ships with git. Both give the same result.
|
|
93
|
+
|
|
94
|
+
Needs Python 3.10+ and git. It installs both a `cleanmsg` command and `git cleanmsg`.
|
|
95
|
+
|
|
96
|
+
From source:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
git clone https://github.com/enikakis/cleanmsg && cd cleanmsg
|
|
100
|
+
pipx install ".[fast]"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Usage
|
|
104
|
+
|
|
105
|
+
Run it inside a repository. **Nothing is changed unless you pass `--apply`.**
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
cleanmsg --ai # preview: which AI lines would go
|
|
109
|
+
cleanmsg --ai --apply # rewrite the current branch locally
|
|
110
|
+
cleanmsg --ai --apply --push # ... and force-push to GitHub
|
|
111
|
+
cleanmsg "WIP" --last 5 --apply # only the last 5 commits
|
|
112
|
+
cleanmsg -e "[skip ci]" -e "fixup" --unpushed --apply
|
|
113
|
+
cleanmsg -E 'JIRA-\d+' --apply # regular expression
|
|
114
|
+
cleanmsg --undo # put the old history back
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### What to remove
|
|
118
|
+
|
|
119
|
+
| Option | |
|
|
120
|
+
|---|---|
|
|
121
|
+
| `TEXT` / `-e TEXT` | text to remove; give as many as you like |
|
|
122
|
+
| `--ai` | AI attribution lines (see below) |
|
|
123
|
+
| `-E`, `--regex` | treat TEXT as a regular expression, matched per line |
|
|
124
|
+
| `-i`, `--ignore-case` | match regardless of case |
|
|
125
|
+
|
|
126
|
+
A line that only contained the removed text is deleted entirely. Leftover
|
|
127
|
+
double spaces are collapsed. If a message would end up empty, it is left as is.
|
|
128
|
+
Messages without a match are not touched, so those commits keep their hash.
|
|
129
|
+
|
|
130
|
+
### Which commits
|
|
131
|
+
|
|
132
|
+
| Option | |
|
|
133
|
+
|---|---|
|
|
134
|
+
| *(default)* | the whole current branch |
|
|
135
|
+
| `--last N` | only the last N commits |
|
|
136
|
+
| `--unpushed` | only commits that aren't on the upstream branch yet (no force-push needed) |
|
|
137
|
+
| `--all` | every local branch and tag |
|
|
138
|
+
|
|
139
|
+
### Actions
|
|
140
|
+
|
|
141
|
+
| Option | |
|
|
142
|
+
|---|---|
|
|
143
|
+
| `--apply` | actually rewrite (otherwise: preview only) |
|
|
144
|
+
| `--push` | force-push the rewritten branches (and tags) to their remote |
|
|
145
|
+
| `-y` | don't ask for confirmation |
|
|
146
|
+
| `-v` | list every affected commit (the preview shows the first 20) |
|
|
147
|
+
| `-C PATH` | run on another repository |
|
|
148
|
+
|
|
149
|
+
### What `--ai` removes
|
|
150
|
+
|
|
151
|
+
Whole lines like these (case-insensitive):
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
155
|
+
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
|
156
|
+
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
|
157
|
+
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
|
|
158
|
+
Co-authored-by: aider (gpt-4o) <noreply@aider.chat>
|
|
159
|
+
🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
160
|
+
Generated by GitHub Copilot
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Also Codex, ChatGPT, Gemini, Devin, Windsurf, Codeium, Amazon Q, Jules, Junie, Cline,
|
|
164
|
+
Roo Code and opencode. Human co-authors (`Co-authored-by: Jane <jane@example.com>`)
|
|
165
|
+
are kept. Run `cleanmsg --show-ai-patterns` for the exact regular expressions.
|
|
166
|
+
Missing a tool? Open an issue or PR.
|
|
167
|
+
|
|
168
|
+
## Safety
|
|
169
|
+
|
|
170
|
+
Rewriting history is the scary part, so `cleanmsg` is careful about it:
|
|
171
|
+
|
|
172
|
+
- **Preview by default.** You see every line that will go before anything happens.
|
|
173
|
+
- **Confirmation** before rewriting or pushing (skip with `-y`).
|
|
174
|
+
- **Backups.** Before every rewrite the old branches and tags are saved under
|
|
175
|
+
`refs/cleanmsg-backup/<time>/`. `cleanmsg --undo` restores the latest one
|
|
176
|
+
(`--undo --push` restores GitHub too). See them with `--list-backups` and delete
|
|
177
|
+
them with `--drop-backups`.
|
|
178
|
+
- **`--force-with-lease`** instead of a plain force-push: if someone pushed in the
|
|
179
|
+
meantime, the push is refused instead of overwriting their work.
|
|
180
|
+
- **GitHub checks.** If the [`gh`](https://cli.github.com) CLI is installed and logged
|
|
181
|
+
in, `cleanmsg` warns you before pushing to a **protected branch** or a branch with
|
|
182
|
+
**open pull requests** (turn off with `--no-github-checks`).
|
|
183
|
+
- Refuses to run with uncommitted changes.
|
|
184
|
+
|
|
185
|
+
### Things to know
|
|
186
|
+
|
|
187
|
+
- Changing a commit message changes that commit's hash **and the hash of every
|
|
188
|
+
commit after it**. That is why a force-push is needed, and why anyone else with a
|
|
189
|
+
clone needs to reset to the new history (`git fetch && git reset --hard origin/main`).
|
|
190
|
+
It's best on your own repos or branches.
|
|
191
|
+
- Rewritten commits lose their GPG/SSH **signatures**.
|
|
192
|
+
- **This is not a way to scrub secrets.** GitHub can keep old commits reachable by
|
|
193
|
+
their hash, and pull requests keep their own copies. If you committed a password or
|
|
194
|
+
key, rotate it, and follow GitHub's guide to
|
|
195
|
+
[removing sensitive data](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository).
|
|
196
|
+
|
|
197
|
+
## How it works
|
|
198
|
+
|
|
199
|
+
`cleanmsg` reads the messages with `git log` to build the preview. When you apply,
|
|
200
|
+
it hands the same cleaning function to `git filter-repo` (if installed) or
|
|
201
|
+
`git filter-branch`, limited to the commits you chose. Authors, dates and file
|
|
202
|
+
contents stay exactly the same; only the messages change.
|
|
203
|
+
|
|
204
|
+
## Development
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
python -m pip install pytest git-filter-repo
|
|
208
|
+
python -m pytest # runs the end-to-end tests with both engines
|
|
209
|
+
./bin/cleanmsg --help # run from the checkout without installing
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
[MIT](LICENSE)
|
cleanmsg-0.1.0/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# cleanmsg
|
|
2
|
+
|
|
3
|
+
**Remove AI attribution lines, or any text, from your git commit messages. Safely.**
|
|
4
|
+
|
|
5
|
+
AI coding tools like to sign their work. After a while your history looks like this:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
Add login form
|
|
9
|
+
|
|
10
|
+
🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
11
|
+
|
|
12
|
+
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Whether you keep those lines is your call (some projects require them). If you
|
|
16
|
+
don't want them, `cleanmsg` strips them out of existing commits: it shows you what
|
|
17
|
+
will change first, keeps a backup, and can force-push the result to GitHub.
|
|
18
|
+
|
|
19
|
+
It works for any text, too: `WIP`, `[skip ci]`, a ticket number, a typo you
|
|
20
|
+
repeated in 40 commits.
|
|
21
|
+
|
|
22
|
+
## Example
|
|
23
|
+
|
|
24
|
+
```console
|
|
25
|
+
$ cleanmsg --ai
|
|
26
|
+
3 commit message(s) to change in branch 'main':
|
|
27
|
+
88912d10 Add password reset flow
|
|
28
|
+
- 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
29
|
+
- Co-Authored-By: Claude <noreply@anthropic.com>
|
|
30
|
+
d4de968e Validate e-mail on submit
|
|
31
|
+
- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
|
32
|
+
52744c5d Add login form
|
|
33
|
+
- 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
34
|
+
- Co-Authored-By: Claude <noreply@anthropic.com>
|
|
35
|
+
|
|
36
|
+
Preview only, nothing changed. Add --apply to rewrite (and --push to update GitHub).
|
|
37
|
+
|
|
38
|
+
$ cleanmsg --ai --apply --push
|
|
39
|
+
...
|
|
40
|
+
Rewrite and force-push branch 'main'? [y/N] y
|
|
41
|
+
Rewriting with git filter-repo...
|
|
42
|
+
Done. Backup saved as 20261127-135715 (undo with: cleanmsg --undo)
|
|
43
|
+
Force-pushing main -> origin/main
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Afterwards the commit reads just:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
Add login form
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Removing your own text works the same way:
|
|
53
|
+
|
|
54
|
+
```console
|
|
55
|
+
$ cleanmsg "my change"
|
|
56
|
+
1 commit message(s) to change in branch 'main':
|
|
57
|
+
169560e2 fix login my change
|
|
58
|
+
- fix login my change
|
|
59
|
+
+ fix login
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Install
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pipx install "cleanmsg[fast]" # or: uv tool install "cleanmsg[fast]"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`[fast]` also installs [git-filter-repo](https://github.com/newren/git-filter-repo),
|
|
69
|
+
which makes rewriting large repos much faster. Without it, `cleanmsg` falls back to
|
|
70
|
+
the `git filter-branch` command that ships with git. Both give the same result.
|
|
71
|
+
|
|
72
|
+
Needs Python 3.10+ and git. It installs both a `cleanmsg` command and `git cleanmsg`.
|
|
73
|
+
|
|
74
|
+
From source:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
git clone https://github.com/enikakis/cleanmsg && cd cleanmsg
|
|
78
|
+
pipx install ".[fast]"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
|
|
83
|
+
Run it inside a repository. **Nothing is changed unless you pass `--apply`.**
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
cleanmsg --ai # preview: which AI lines would go
|
|
87
|
+
cleanmsg --ai --apply # rewrite the current branch locally
|
|
88
|
+
cleanmsg --ai --apply --push # ... and force-push to GitHub
|
|
89
|
+
cleanmsg "WIP" --last 5 --apply # only the last 5 commits
|
|
90
|
+
cleanmsg -e "[skip ci]" -e "fixup" --unpushed --apply
|
|
91
|
+
cleanmsg -E 'JIRA-\d+' --apply # regular expression
|
|
92
|
+
cleanmsg --undo # put the old history back
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### What to remove
|
|
96
|
+
|
|
97
|
+
| Option | |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `TEXT` / `-e TEXT` | text to remove; give as many as you like |
|
|
100
|
+
| `--ai` | AI attribution lines (see below) |
|
|
101
|
+
| `-E`, `--regex` | treat TEXT as a regular expression, matched per line |
|
|
102
|
+
| `-i`, `--ignore-case` | match regardless of case |
|
|
103
|
+
|
|
104
|
+
A line that only contained the removed text is deleted entirely. Leftover
|
|
105
|
+
double spaces are collapsed. If a message would end up empty, it is left as is.
|
|
106
|
+
Messages without a match are not touched, so those commits keep their hash.
|
|
107
|
+
|
|
108
|
+
### Which commits
|
|
109
|
+
|
|
110
|
+
| Option | |
|
|
111
|
+
|---|---|
|
|
112
|
+
| *(default)* | the whole current branch |
|
|
113
|
+
| `--last N` | only the last N commits |
|
|
114
|
+
| `--unpushed` | only commits that aren't on the upstream branch yet (no force-push needed) |
|
|
115
|
+
| `--all` | every local branch and tag |
|
|
116
|
+
|
|
117
|
+
### Actions
|
|
118
|
+
|
|
119
|
+
| Option | |
|
|
120
|
+
|---|---|
|
|
121
|
+
| `--apply` | actually rewrite (otherwise: preview only) |
|
|
122
|
+
| `--push` | force-push the rewritten branches (and tags) to their remote |
|
|
123
|
+
| `-y` | don't ask for confirmation |
|
|
124
|
+
| `-v` | list every affected commit (the preview shows the first 20) |
|
|
125
|
+
| `-C PATH` | run on another repository |
|
|
126
|
+
|
|
127
|
+
### What `--ai` removes
|
|
128
|
+
|
|
129
|
+
Whole lines like these (case-insensitive):
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
133
|
+
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
|
134
|
+
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
|
135
|
+
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
|
|
136
|
+
Co-authored-by: aider (gpt-4o) <noreply@aider.chat>
|
|
137
|
+
🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
138
|
+
Generated by GitHub Copilot
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Also Codex, ChatGPT, Gemini, Devin, Windsurf, Codeium, Amazon Q, Jules, Junie, Cline,
|
|
142
|
+
Roo Code and opencode. Human co-authors (`Co-authored-by: Jane <jane@example.com>`)
|
|
143
|
+
are kept. Run `cleanmsg --show-ai-patterns` for the exact regular expressions.
|
|
144
|
+
Missing a tool? Open an issue or PR.
|
|
145
|
+
|
|
146
|
+
## Safety
|
|
147
|
+
|
|
148
|
+
Rewriting history is the scary part, so `cleanmsg` is careful about it:
|
|
149
|
+
|
|
150
|
+
- **Preview by default.** You see every line that will go before anything happens.
|
|
151
|
+
- **Confirmation** before rewriting or pushing (skip with `-y`).
|
|
152
|
+
- **Backups.** Before every rewrite the old branches and tags are saved under
|
|
153
|
+
`refs/cleanmsg-backup/<time>/`. `cleanmsg --undo` restores the latest one
|
|
154
|
+
(`--undo --push` restores GitHub too). See them with `--list-backups` and delete
|
|
155
|
+
them with `--drop-backups`.
|
|
156
|
+
- **`--force-with-lease`** instead of a plain force-push: if someone pushed in the
|
|
157
|
+
meantime, the push is refused instead of overwriting their work.
|
|
158
|
+
- **GitHub checks.** If the [`gh`](https://cli.github.com) CLI is installed and logged
|
|
159
|
+
in, `cleanmsg` warns you before pushing to a **protected branch** or a branch with
|
|
160
|
+
**open pull requests** (turn off with `--no-github-checks`).
|
|
161
|
+
- Refuses to run with uncommitted changes.
|
|
162
|
+
|
|
163
|
+
### Things to know
|
|
164
|
+
|
|
165
|
+
- Changing a commit message changes that commit's hash **and the hash of every
|
|
166
|
+
commit after it**. That is why a force-push is needed, and why anyone else with a
|
|
167
|
+
clone needs to reset to the new history (`git fetch && git reset --hard origin/main`).
|
|
168
|
+
It's best on your own repos or branches.
|
|
169
|
+
- Rewritten commits lose their GPG/SSH **signatures**.
|
|
170
|
+
- **This is not a way to scrub secrets.** GitHub can keep old commits reachable by
|
|
171
|
+
their hash, and pull requests keep their own copies. If you committed a password or
|
|
172
|
+
key, rotate it, and follow GitHub's guide to
|
|
173
|
+
[removing sensitive data](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository).
|
|
174
|
+
|
|
175
|
+
## How it works
|
|
176
|
+
|
|
177
|
+
`cleanmsg` reads the messages with `git log` to build the preview. When you apply,
|
|
178
|
+
it hands the same cleaning function to `git filter-repo` (if installed) or
|
|
179
|
+
`git filter-branch`, limited to the commits you chose. Authors, dates and file
|
|
180
|
+
contents stay exactly the same; only the messages change.
|
|
181
|
+
|
|
182
|
+
## Development
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
python -m pip install pytest git-filter-repo
|
|
186
|
+
python -m pytest # runs the end-to-end tests with both engines
|
|
187
|
+
./bin/cleanmsg --help # run from the checkout without installing
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "cleanmsg"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Remove AI attribution lines (Co-Authored-By: Claude, Copilot, Cursor...) or any text from git commit messages, safely."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "enikakis" }]
|
|
14
|
+
keywords = ["git", "commit-message", "rewrite-history", "co-authored-by", "claude", "copilot", "ai", "cli"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Environment :: Console",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Operating System :: MacOS",
|
|
20
|
+
"Operating System :: POSIX :: Linux",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Topic :: Software Development :: Version Control :: Git",
|
|
23
|
+
]
|
|
24
|
+
dependencies = []
|
|
25
|
+
|
|
26
|
+
[project.optional-dependencies]
|
|
27
|
+
fast = ["git-filter-repo"]
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
cleanmsg = "cleanmsg.cli:run"
|
|
31
|
+
git-cleanmsg = "cleanmsg.cli:run"
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/enikakis/cleanmsg"
|
|
35
|
+
Issues = "https://github.com/enikakis/cleanmsg/issues"
|
|
36
|
+
|
|
37
|
+
[tool.hatch.version]
|
|
38
|
+
path = "src/cleanmsg/__init__.py"
|
|
39
|
+
|
|
40
|
+
[tool.hatch.build.targets.wheel]
|
|
41
|
+
packages = ["src/cleanmsg"]
|
|
42
|
+
|
|
43
|
+
[tool.pytest.ini_options]
|
|
44
|
+
testpaths = ["tests"]
|
|
45
|
+
pythonpath = ["src"]
|