🐌 feat: skip auto-commit while a manual commit is in progress - #4
Open
sdougbrown wants to merge 1 commit into
Open
🐌 feat: skip auto-commit while a manual commit is in progress#4sdougbrown wants to merge 1 commit into
sdougbrown wants to merge 1 commit into
Conversation
Read-write mode could commit a repo while the user was composing a commit message in an editor, tending it out from under them. Git holds no lock during the editor phase, so detect an in-progress commit via a fresh .git/COMMIT_EDITMSG and back off for a configurable window. Add commit.in_progress_window (opt-in, off by default). Always back off in read-write mode while any .git/*.lock is present. Clear COMMIT_EDITMSG after git-tend's own auto-commit so it does not back off against itself.
There was a problem hiding this comment.
This PR is marked... SAFE! 🙌
Must fix
- [confidence: 95] internal/git/git_test.go -
ClearCommitEditMsgis not tested, leaving its behavior for both existing and non-existingCOMMIT_EDITMSGfiles unverified. - [confidence: 90] internal/sync/sync_test.go -
syncReadWritedoes not test the case wheregit.ActiveLocksreturnstrue, failing to verify the new integration branch that skips synchronization when a git lock is detected.
Should fix
- [confidence: 75] internal/git/git_test.go -
GitDirerror paths (e.g., when the underlying git command fails) are not explicitly tested.
Must fix
- [confidence: 95] internal/git/git_test.go: ClearCommitEditMsg is not tested. This function is used in the core sync loop to clean up the COMMIT_EDITMSG sentinel after an auto-commit; its behavior in both successful removal and non-existent file scenarios is unverified.
- [confidence: 90] internal/sync/sync_test.go: The branch in syncReadWrite that handles git.ActiveLocks returning true is not covered. A test should be added to verify that Sync returns skipped when a .lock file is detected in the repository's .git directory.
Should fix
- [confidence: 75] internal/git/git_test.go: GitDir is not tested in isolation. As an exported function, its error paths (e.g. when the underlying git command fails) should be explicitly exercised.
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.
In read-write mode the daemon stages and auto-commits on its interval. When a manual
git commitwas mid-composition in an editor, the daemon could commit the same staged content with a generated message and push, tending the repo out from under the user. Git holds no lock during the editor phase, so this change detects an in-progress commit via a fresh.git/COMMIT_EDITMSGand backs off.internal/git: addGitDir,ActiveLocks,CommitEditRecent,ClearCommitEditMsg.internal/sync: skip auto-commit in read-write mode while any.git/*.lockis present; whenin_progress_windowis set, also skip whileCOMMIT_EDITMSGis fresh; clearCOMMIT_EDITMSGafter git-tend's own auto-commit so it does not back off against itself.internal/config: addcommit.in_progress_window(TOML string duration, validated).README.md: document the new option and its trade-off.Behavior is opt-in and off by default; existing read-write behavior is unchanged unless
in_progress_windowis set.Validation:
go build ./...— okgo test ./internal/git/ ./internal/sync/ ./internal/config/— passgo test ./...— pass; one pre-existing failure incmd/git-tend(TestRunStatusEmptyRepos) also fails onmain, unrelated to this changeKnown limitation: because git leaves
COMMIT_EDITMSGaround after a finished commit, enabling this also leaves a quiet window after a manual commit before auto-commit resumes. The window length is user-controlled.