Repository navigation
feat: reload by itself when the working tree or refs change - #10
Merged
Merged
Conversation
Merged
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.
What this changes
GitCraft now notices changes made outside it and reloads by itself: a file saved in an editor,
git add, a commit, a new branch or a checkout in a terminal show up within a moment, without clicking Refresh or switching windows.gitcraft-coregetsRepo::watch(watch.rs), built on notify (CC0-1.0) for the native file events on every platform. It watches the working tree and the git directory and only reports what GitCraft shows: files git does not ignore (gitoxide's own ignore rules, read again when a.gitignoreorinfo/excludechanges), refs,HEADand the index. Objects, logs, lock files and plain reads do not count, so a build intarget/ornode_modules/does not wake the app.git statusnow runs with--no-optional-locks. Without it, the reload after a change could rewrite the index, which wakes the watcher again and briefly holdsindex.lock, making the user's owngitin a terminal fail.How it is tested
changes_made_outside_are_noticed(core): an edited file, staging, a new branch and a checkout from the command line are each reported.ignored_files_and_reading_are_not_noticed(core): writing in an ignored folder, reading the history, the status, the stashes and a diff report nothing; after.gitignorechanges, the same folder is reported. Checked that the test fails without--no-optional-locks, without skipping read events and without the ignore rules.On macOS, FSEvents can still report changes made just before watching began (seen in CI with printed events: reads themselves report nothing there either). The core tests let those early reports pass first; in the app they cost at most one extra reload when a tab opens.
changes_made_outside_show_up_by_themselves(app): an edit and a commit made outside show up in the window on their own; the test fails when the watcher is off.Tried on the desktop with the release build: a new file and a branch made from a terminal appeared within a second, removing them again restored the view. Idle CPU stays at zero; 1,500 writes to an ignored folder cost about 50 ms of CPU in total.
cargo fmt --all,cargo clippy --workspace --all-targets -- -D warningsandcargo test --workspacepassIt adds as little code as the change needs, and removes what it makes unnecessary
Nothing in it comes from GitKraken or another closed-source client (see CONTRIBUTING.md)