Skip to content

Conversation

@adripo
Copy link

@adripo adripo commented Oct 24, 2025

Introduce a debounce mechanism to the repository watcher and add a check for staged files before triggering the handler.

fix #12

@D3vanshC
Copy link
Collaborator

Hey @adripo , thanks for the PR — the debounce and staged file check work well.
However, I noticed that onFilesStaged() still gets triggered right after a git commit, which shouldn’t happen since commits rewrite .git/index and fire another change event.

You might want to add a small safeguard to ignore .git/index updates caused by commits. One way is to detect recent HEAD changes using git rev-parse HEAD and skip the trigger for a short cooldown (e.g., 1s) whenever the commit hash changes. That should ensure the watcher only reacts to actual git add operations.

Everything else in the update looks good.

@adripo
Copy link
Author

adripo commented Oct 30, 2025

@D3vanshC Thanks for the check and the hint. I just updated the script to ignore .git/index updates caused by commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix(watcher): prevent onFilesStaged() from triggering after commit by filtering .git/index updates

2 participants