Skip to content

Commit 0896d06

Browse files
committed
refactor: migrate checkout_files_at_commit, restore_all, and restore_from_branch_ref to git2 (#311)
## Summary Port the following methods to git2: - `checkout_files_at_commit` - `restore_all` - `restore_from_branch_ref` I also verified that these are actually used, which is not something to take for granted. I had delayed taking these on because they rely on behavior of `git clean -fd` which doesn't have a direct analogue in git2, but now we have an implementation in the helper method `remove_untracked`. I should point out that the previous CLI-based methods had some weird behavior which is _not_ replicated namely to reset the entire repo but only clean under the target dir, which I imagine is an artifact of when we were assuming that the "config dir" and the "repo dir" were always one and the same. I added tests to pin the new behavior which I think was intended by the API contract and the HEAD reset, namely, cleaning the entire repo when we simulate `-fd`. @czxtm let me know if you have any concerns about this. <!-- What does this PR do? Why? --> ## Test Plan Ran through several manual tests in addition to verifying that the several existing unit tests still pass, and added a number of new unit tests in the process. - [ ] No test plan needed ## Docs - [ ] Docs updated (companion PR in darkmatter/nixmac-web: #\___) - [x] No docs update needed <!-- codesmith:footer --> --- <picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v2.svg"><img alt="View with Codesmith" src="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"></picture> <picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with Codesmith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"></picture> <sup>Need help on this PR? Tag `/codesmith` with what you need. Autofix is disabled.</sup> <!-- codesmith:autofix:disabled --> <!-- /codesmith:footer -->
1 parent a60a965 commit 0896d06

1 file changed

Lines changed: 355 additions & 56 deletions

File tree

  • apps/native/src-tauri/src/git

0 commit comments

Comments
 (0)