Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
Pull request overview
This PR updates gitbutler_operating_modes::operating_mode to use the gix repository from but_ctx::Context instead of unwrapping the legacy git2 repo, preventing panics and allowing the function to fail gracefully.
Changes:
- Replaced
ctx.git2_repo.get().unwrap()withctx.repo.get()and added graceful fallback toOperatingMode::OutsideWorkspaceon failure. - Switched HEAD reference name inspection/comparisons to
gix(referent_name()+ byte-wise comparisons) for workspace/edit branch detection.
cbe5415 to
14ab770
Compare
14ab770 to
ac77abb
Compare
ac77abb to
6f1e271
Compare
|
@krlvi I just want to make sure I understand the problem we're solving here. It looks like the function may be getting called in cases where there isn’t a git repository. If that’s the case, I’m not sure returning Also, with hindsight, unwrapping here seems like a bad idea, so we should probably refactor it to be a Would it make sense to update the return type to WDYT? |
My objectives were:
Happy to change the api, but im wondering if we want to go from But I am also thinking, since "operating mode" is generic enough, maybe there could be a variant for "not a git repo" ? |
I think it would be helpful to refactor this to return a result while we're looking at it. I'm happy to take this on if you'd like. After giving it some thought, I like the idea of using an |
Okay feel free to take over this thing but only if you have the bandwidth for it (i.e. it's not interfering with the rebase engine stuff). If you wanna take it, just close this PR |
|
ping @Caleb-T-Owens how should we do here? |
6f1e271 to
1b8ed02
Compare
Motivation
git2repository.gixsooperating_modecan fail gracefully.Description
gitbutler_operating_modes::operating_modenow usesctx.repo.get()(gix) instead ofctx.git2_repo.get().unwrap().OperatingMode::OutsideWorkspace(no panics). If the repo handle can't be opened/borrowed, we returnOutsideWorkspaceMetadata::default()directly.gix(head().referent_name()) and compares againstOPEN_WORKSPACE_REFS/EDIT_BRANCH_REFvia byte-wise comparisons.Files:
crates/gitbutler-operating-modes/src/lib.rsRegression coverage added:
.gitremoved).gitbutler/editwithout edit-mode metadata.