fix: reduce history rewrites#2
Merged
harper-new-line[bot] merged 3 commits intomainfrom Apr 9, 2026
Merged
Conversation
Contributor
HarperBotThe provided diff shows changes to Here's an analysis of the visible changes: 1.
2.
README.md
@@ -6,9 +6,4 @@
Next, install the app on your desired repository or organization. Then, set the required environment variables: `GITHUB_APP_ID` with your app's ID, `GITHUB_PRIVATE_KEY` with the content of the private key file (paste the entire PEM content), and `GITHUB_WEBHOOK_SECRET` with the webhook secret you generated. Run the app locally with `python github_app.py` for testing, or deploy it to a production server like Render, Heroku, or AWS, updating the webhook URL accordingly to ensure it's publicly accessible.
-The app operates by receiving push webhooks from GitHub. When a push is made to a repository where the app is installed, GitHub sends a webhook payload to your deployed app endpoint. The app then generates an installation access token using the installation ID from the webhook, clones the repository using that token for authentication, checks out the affected branch, and executes `git filter-branch` to modify commit messages by removing " add ", " Add ", leading "add ", or leading "Add " phrases. Finally, it force pushes the rewritten history back to the branch, skipping actions if the push originated from a bot to prevent infinite loops.
-
-Be warned that this app rewrites git history, which is a destructive operation that can overwrite remote commits and affect collaborators. Always back up your repository before using it
+The app operates by receiving push webhooks from GitHub. When a push is made to a repository where the app is installed, GitHub sends a webhook payload to your deployed app endpoint. The app then generates an installation access token, clones the repository, checks out the affected branch, and identifies new commits relative to the default branch. It then rewrites the messages of these new commits, if necessary, by removing " add ", " Add ", leading "add ", or leading "Add " phrases. The rewritten history is then pushed back to the branch using `--force-with-lease` to ensure safer updates. The app skips rewriting the repository's default branch and also skips actions if the push originated from a bot to prevent infinite loops.
+
+While the app uses `--force-with-lease` for safer history rewriting, it is still a destructive operation that modifies commit history. Exercise caution and ensure collaborators are aware of its behavior.3.
Missing Diffs: The absence of diffs for
|
Co-authored-by: harper-new-line[bot] <268319948+harper-new-line[bot]@users.noreply.github.com>
Co-authored-by: harper-new-line[bot] <268319948+harper-new-line[bot]@users.noreply.github.com>
Comment on lines
8
to
10
|
|
||
| The app operates by receiving push webhooks from GitHub. When a push is made to a repository where the app is installed, GitHub sends a webhook payload to your deployed app endpoint. The app then generates an installation access token using the installation ID from the webhook, clones the repository using that token for authentication, checks out the affected branch, and executes `git filter-branch` to modify commit messages by removing " add ", " Add ", leading "add ", or leading "Add " phrases. Finally, it force pushes the rewritten history back to the branch, skipping actions if the push originated from a bot to prevent infinite loops. | ||
|
|
||
| Be warned that this app rewrites git history, which is a destructive operation that can overwrite remote commits and affect collaborators. Always back up your repository before using it, and communicate with your team to avoid conflicts. | ||
| The app operates by receiving push webhooks from GitHub. When a push is made to a repository where the app is installed, GitHub sends a webhook payload to your deployed app endpoint. The app then generates an installation access token using the installation ID from the webhook, clones the repository using that token for authentication, checks out the affected branch, and identifies commits unique to it (relative to the default branch). It then modifies commit messages in these unique commits by removing " add ", " Add ", leading "add ", or leading "Add " phrases. Finally, it pushes the rewritten history back to the branch using `--force-with-lease`, skipping the repository's default branch and actions if the push originated from a bot to prevent infinite loops. | ||
|
|
Contributor
There was a problem hiding this comment.
Suggested change
| The app operates by receiving push webhooks from GitHub. When a push is made to a repository where the app is installed, GitHub sends a webhook payload to your deployed app endpoint. The app then generates an installation access token using the installation ID from the webhook, clones the repository using that token for authentication, checks out the affected branch, and executes `git filter-branch` to modify commit messages by removing " add ", " Add ", leading "add ", or leading "Add " phrases. Finally, it force pushes the rewritten history back to the branch, skipping actions if the push originated from a bot to prevent infinite loops. | |
| Be warned that this app rewrites git history, which is a destructive operation that can overwrite remote commits and affect collaborators. Always back up your repository before using it, and communicate with your team to avoid conflicts. | |
| The app operates by receiving push webhooks from GitHub. When a push is made to a repository where the app is installed, GitHub sends a webhook payload to your deployed app endpoint. The app then generates an installation access token using the installation ID from the webhook, clones the repository using that token for authentication, checks out the affected branch, and identifies commits unique to it (relative to the default branch). It then modifies commit messages in these unique commits by removing " add ", " Add ", leading "add ", or leading "Add " phrases. Finally, it pushes the rewritten history back to the branch using `--force-with-lease`, skipping the repository's default branch and actions if the push originated from a bot to prevent infinite loops. | |
| The app operates by receiving push webhooks from GitHub. When a push is made to a repository where the app is installed, GitHub sends a webhook payload to your deployed app endpoint. The app then generates an installation access token, clones the repository, checks out the affected branch, and identifies new commits relative to the default branch. It then rewrites the messages of these new commits, if necessary, by removing " add ", " Add ", leading "add ", or leading "Add " phrases. The rewritten history is then pushed back to the branch using `--force-with-lease` to ensure safer updates. The app skips rewriting the repository's default branch and also skips actions if the push originated from a bot to prevent infinite loops. | |
| While the app uses `--force-with-lease` for safer history rewriting, it is still a destructive operation that modifies commit history. Exercise caution and ensure collaborators are aware of its behavior. |
Member
Author
|
/merge |
Contributor
|
Merged via merge by HarperBot. |
harper-new-line Bot
added a commit
that referenced
this pull request
Apr 10, 2026
See #2 for details. Tested on test-commit-fix repo: path-harper/test-commit-fix#1 Changes: - Only rewrite commits when message actually changes - Only rewrite commits unique to the pushed branch (relative to default branch) - Skip default branch entirely - Use --force-with-lease instead of --force - Fix empty commit message bug by using Python directly in filter script Test results: - Pushed commit with "add" prefix to non-default branch (https://github.com/path-harper/test-commit-fix/tree/main2) -> correctly rewrote to remove "add" - Pushed commit with "add" prefix to default branch (https://github.com/path-harper/test-commit-fix/tree/main, commit bd6e227) -> correctly skipped rewriting Deploy note: - Currently testing with Render deploy pointing to this PR branch - After merge, switch Render deploy back to main (this becomes the new production app) Changelog updated for v1.5.0. --------- Co-authored-by: Niladri Das <bniladridas@users.noreply.github.com> Co-authored-by: harper-new-line[bot] <268319948+harper-new-line[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
honest truth
this app rewrites git history by design (it edits commit messages and force-pushes). the pr issue you saw (history constantly changing) is expected with the previous behavior because it rewrote on every push.
what changed
limits/risks
testing