Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkout commit #1499

Merged
merged 12 commits into from
Feb 4, 2023
Merged

Checkout commit #1499

merged 12 commits into from
Feb 4, 2023

Conversation

fralcow
Copy link
Contributor

@fralcow fralcow commented Jan 7, 2023

This Pull Request fixes/closes #983

It changes the following:

  • Adds a command to a log view to checkout a specific commit
  • Added an entry to the log bottom hint bar with command name and a key to execute it.

I followed the checklist:

  • I added unittests
  • I ran make check without errors -- sync::submodules::tests::test_smoke throws an error for me, both in master and my branch: Error { code: -1, klass: 16, message: "the server did not provide a certificate" }. I would appreciate some help fixing this.
  • I tested the overall application
  • I added an appropriate item to the changelog

The PR by the original author went stale, I hope we can add this function in this PR.

@fralcow fralcow marked this pull request as ready for review January 7, 2023 12:49
repo.set_head_detached(commit_hash.into())?;

if let Err(e) = repo.checkout_head(Some(
git2::build::CheckoutBuilder::new().force(),
Copy link
Owner

Choose a reason for hiding this comment

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

this will overwrite changes made to the index, right? I am not sure we want force to be true

Copy link
Owner

Choose a reason for hiding this comment

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

I tested, it in fact will fail with an Err if there are uncommitted changes. se more comments below

Copy link
Owner

@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.

small improvement on the error handling and this is good to go 💪

repo.set_head_detached(commit_hash.into())?;

if let Err(e) = repo.checkout_head(Some(
git2::build::CheckoutBuilder::new().force(),
Copy link
Owner

Choose a reason for hiding this comment

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

I tested, it in fact will fail with an Err if there are uncommitted changes. se more comments below

src/components/commitlist.rs Outdated Show resolved Hide resolved
@fralcow
Copy link
Contributor Author

fralcow commented Jan 31, 2023

Thank you for your comments! I've fixed the code, let me know if more stuff needs fixing. 💪

@extrawurst extrawurst merged commit 57a5322 into extrawurst:master Feb 4, 2023
@extrawurst
Copy link
Owner

Thank you @fralcow

IndianBoy42 pushed a commit to IndianBoy42/gitui that referenced this pull request Jun 4, 2024
* Add keybind to checkout commit in log view
* Extract commit checkout into method
* add quckbar hint for checkout commit
* add a smoke test
* update changelog
* show an error in popup

---------

Co-authored-by: Omnikar <omnikar5@gmail.com>
Co-authored-by: extrawurst <776816+extrawurst@users.noreply.github.com>
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.

[Feature] Allow checking out specific commits in log view
3 participants