Skip to content

Conversation

@Fatpandac
Copy link
Contributor

@Fatpandac Fatpandac commented Jan 20, 2025

This Pull Request fixes/closes #2404.

It changes the following:

  • support choosing checkout branch method when status is not empty
  • add .editorconfig file

image

I followed the checklist:

  • I added unittests
  • I ran make check without errors
  • I tested the overall application
  • I added an appropriate item to the changelog

Copy link
Collaborator

@extrawurst extrawurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this! I left the first round of feedbacks

@Fatpandac Fatpandac requested a review from extrawurst January 29, 2025 04:08
Copy link

@dotslashdan dotslashdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, apologies for the intrusion. i have come across this repo just now and have been poking around. i hope you don't mind but i've left a few comments and questions i have, but don't feel obligated to reply

@extrawurst extrawurst requested review from cruessler and removed request for dotslashdan October 22, 2025 09:25
@extrawurst extrawurst removed their request for review October 28, 2025 16:04
@extrawurst extrawurst added this to the v0.28 milestone Oct 28, 2025
Copy link
Collaborator

@extrawurst extrawurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@extrawurst
Copy link
Collaborator

extrawurst commented Oct 28, 2025

I have looked at this a while ago extensively. Would like a second pair of eyes @cruessler - please give it a go aswell locally, not just by code-review so we do not miss potential regressions. give me a merge_ready when you think its good

Copy link
Collaborator

@cruessler cruessler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR is already in a good state. I just have a couple of comments, mostly minor.

I also tested it locally and did not find any issues so far.

Comment on lines 99 to 109
if self.local {
checkout_branch(
&self.repo,
&self.branch.as_ref().expect("No branch").name,
)?;
} else {
checkout_remote_branch(
&self.repo,
self.branch.as_ref().expect("No branch"),
)?;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense, perhaps as a follow-up, to extract this code that is very similar to existing code in BranchListPopup::switch_to_selected_branch into a shared location?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I add a checkout method to BranchInfo?

Copy link
Collaborator

@extrawurst extrawurst Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets as much as possible layer this new functionality on top. So we do not have to change as many existing tests.
So lets do a new checkout_with_method in asyncgit that bundles the logic you did now inside our App, method can then be a parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don’t fully understand what you mean. Do you mean I should implement a function called checkout_with_method in asyncgit::BranchInfo, which performs the checkout and then runs some additional effect functions through a callback parameter?

@extrawurst
Copy link
Collaborator

@Fatpandac I compared our behavior when choosing stash and reapply with Forks and ours has one obvious difference that might (at least) confuse:
if you have changes stages and changes to the same file unstaged this will merge these into a single stash and it will have all changes unstaged after the procedure.

Copy link
Collaborator

@extrawurst extrawurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should either fix this and stash staged and unstaged separately or flat out error if we detect that this will happen. Wdyt?

Copy link
Collaborator

@extrawurst extrawurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering the findings I would further argue lets move the logic to checkout with different options to asyncgit and lets cover them with proper unit tests that recreate the various scenarios and the expected results/errors we want to achieve. this is a fundamental enough feature to warrant that quality and resilience for future changes not breaking it

@extrawurst
Copy link
Collaborator

@Fatpandac if the stash staging and non-staged changes is gonna be hard (I assume so, I am not aware we have that machinery yet) then lets for now rip out the stashing option and support only Discard & Keep option that is largely handled by libgit2 and followup with the stashing variants in a followup PR?

@Fatpandac
Copy link
Contributor Author

@extrawurst I agree. I'll remove the KeepLocalChanges option in the next commit.

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.

checkout branch stashing/reapplying changes

4 participants