-
Notifications
You must be signed in to change notification settings - Fork 132
feat(branch): add delete branch functionality #350
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
Conversation
altsem
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. Nice to see this addition!
I got some feedback. See if they make sense.
A few tests are needed too. I found the related ones here:
Lines 260 to 288 in 947da1b
| mod checkout { | |
| use super::*; | |
| #[test] | |
| pub(crate) fn checkout_menu() { | |
| let ctx = TestContext::setup_clone(); | |
| run(ctx.dir.path(), &["git", "branch", "other-branch"]); | |
| snapshot!(ctx, "Yjb"); | |
| } | |
| #[test] | |
| pub(crate) fn switch_branch_selected() { | |
| let ctx = TestContext::setup_clone(); | |
| run(ctx.dir.path(), &["git", "branch", "other-branch"]); | |
| snapshot!(ctx, "Yjjbb<enter>"); | |
| } | |
| #[test] | |
| pub(crate) fn switch_branch_input() { | |
| let ctx = TestContext::setup_clone(); | |
| run(ctx.dir.path(), &["git", "branch", "hi"]); | |
| snapshot!(ctx, "Yjjbbhi<enter>"); | |
| } | |
| #[test] | |
| pub(crate) fn checkout_new_branch() { | |
| snapshot!(TestContext::setup_clone(), "bcf<esc>bcx<enter>"); | |
| } | |
| } |
|
Does it seem better? I've tried to implement all your suggestions. Thanks for the input! Tell me what you think |
altsem
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey. Looks pretty good. I did some testing and found some things still. Good job though. Let's make it great :)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #350 +/- ##
==========================================
- Coverage 86.63% 86.61% -0.03%
==========================================
Files 66 66
Lines 6127 6237 +110
==========================================
+ Hits 5308 5402 +94
- Misses 819 835 +16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thank you a lot for your prompt modifications. It made it a whole lot easier! I've made a new version that you can review. |
altsem
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks pretty good! I have only two requests:
Consistency with "Discard" action
I found some more code while testing it out. This already existing action doesn't support deleting unmerged branches like the new one. It feels fine to have both of them, two different entry-points. K is always at-the-cursor, bK would prompt for a branch.
But perhaps they should share the underlying implementation?
https://github.com/altsem/gitu/blob/master/src/ops/discard.rs#L46-L57
Found here:
https://github.com/altsem/gitu/blob/master/src/ops/discard.rs#L46-L57
The generated changelog is off
gitu on rachartier/master:master ❯ git cliff --unreleased
# Changelog
All notable changes to this project will be documented in this file.
## [unreleased]
### 🚀 Features
- Expose selected branch in state
- *(checkout)* Prompt before deleting unmerged branch
- *(config)* Add 'x' as default keybindings for branch operations
- *(branch)* Add delete branch functionality
see https://github.com/altsem/gitu/blob/master/docs/dev-tooling.md
Some ideas:
feat(branch): Deleting (unmerged) branches via the branch menu
feat(discard): Support for deleteing unmerged branches
| if is_unmerged { | ||
| let branch_to_delete = branch.to_string(); | ||
|
|
||
| match state.confirm(term, "Branch is unmerged. Really delete?") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| match state.confirm(term, "Branch is unmerged. Really delete?") { | |
| match state.confirm(term, "Branch is unmerged. Really delete? (y or n)") { |
Ugly, but...
Let's throw in a (y or n) to make it consistent with the other ones? I should've just taken the effort to bake it into state.confirm, perhaps later.
|
This was picked up in #367, I'll close this. |
Hello,
I've added code to delete a branch by its name, or one selected by branch from
Y.Tell me what you think, and if I need to improve or change something.
Thanks for this amazing project.