-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Delete range selection of branches #4073
Conversation
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more Footnotes
|
e144aad
to
99e4112
Compare
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.
Yass! This is exactly the behavior I was expecting. Thanks a lot! Hope it gets released soon.
Fixes #4041
if len(branches) > 1 { | ||
if lo.SomeBy(branches, func(branch *models.Branch) bool { return self.checkedOutByOtherWorktree(branch) }) { | ||
return errors.New(self.c.Tr.SomeBranchesCheckedOutByWorktreeError) | ||
} |
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.
are we completely disallowing branch deletion if it's checked out by another worktree? I noticed the previous implementation prompted the user first rather than outright rejecting it.
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.
If one of the selected branches is checked out in another worktree, yes. I did this because I found it too complex to wrap my head around what should happen in that case (for a range selection).
If you select those branches one by one, you still get the prompt for what to do with the worktree as before.
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.
LGTM
DeleteRemoteBranchOption: "Delete remote branch", | ||
DeleteRemoteBranchPrompt: "Are you sure you want to delete the remote branch '{{.selectedBranchName}}' from '{{.upstream}}'?", | ||
DeleteRemoteBranchesPrompt: "Are you sure you want to delete the remote branches of the selected branches from their respective remotes?", |
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.
Adding 'from their respective remotes' feels superfluous (likewise in DeleteLocalAndRemoteBranchesPrompt). Thoughts?
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.
I thought it be good to be explicit about the fact that it actually goes to the remote and deletes the branch there (as opposed to only deleting the tracking branch from the local repo, maybe). We are also very explicit about this when deleting a single branch, this is just analogous to that.
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.
Makes sense
Besides being a useful cleanup on its own, it will make it easier to support a multiselection of branches.
Since we want to select multiselections, this will make it easier to pass a slice of remote branches. It does require that for the case of the local branches panel we need to synthesize a RemoteBranch object from the selected local branch, but that's not hard.
We'll need it a few more times in the next test we add.
We allow deleting remote branches (or local and remote branches) only if *all* selected branches have one. We show the a warning about force-deleting as soon as at least one of the selected branches is not fully merged. The added test only tests a few of the most interesting cases; I didn't try to cover the whole space of possible combinations, that would have been too much.
99e4112
to
c1b4201
Compare
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [jesseduffield/lazygit](https://github.com/jesseduffield/lazygit) | minor | `v0.44.1` -> `v0.45.2` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>jesseduffield/lazygit (jesseduffield/lazygit)</summary> ### [`v0.45.2`](https://github.com/jesseduffield/lazygit/releases/tag/v0.45.2) [Compare Source](jesseduffield/lazygit@v0.45.0...v0.45.2) <!-- Release notes generated using configuration in .github/release.yml at v0.45.2 --> #### What's Changed ##### Enhancements 🔥 - Add ability to configure branch color patterns using regex by [@​mtrajano](https://github.com/mtrajano) in jesseduffield/lazygit#4130 - Collapse/uncollapse all files in tree by [@​mtrajano](https://github.com/mtrajano) in jesseduffield/lazygit#4131 - Improve undo action to restore files upon undoing a commit by [@​gabriellanata](https://github.com/gabriellanata) in jesseduffield/lazygit#4167 ##### Fixes 🔧 - Bump gocui (and tcell) by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4166 ##### Maintenance ⚙️ - Cut a new release automatically each month by [@​jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4146 - Bump tcell to fix broken deployment by [@​jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4178 #### New Contributors - [@​mtrajano](https://github.com/mtrajano) made their first contribution in jesseduffield/lazygit#4130 - [@​gabriellanata](https://github.com/gabriellanata) made their first contribution in jesseduffield/lazygit#4167 **Full Changelog**: jesseduffield/lazygit@v0.45.0...v0.45.2 ### [`v0.45.0`](https://github.com/jesseduffield/lazygit/releases/tag/v0.45.0) [Compare Source](jesseduffield/lazygit@v0.44.1...v0.45.0) <!-- Release notes generated using configuration in .github/release.yml at v0.45.0 --> Lots of great improvements in this one! Thanks to all the contributors who helped make this release happen. Apologies for the long waits between releases. As of jesseduffield/lazygit#4146 we're now (almost) guaranteed to do monthly releases. #### What's Changed ##### Enhancements 🔥 - Better branch delete confirmation by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#3915 - Add a menu item to delete both local and remote branch at once by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#3916 - Auto-render hyperlinks by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#3914 - Allow pasting commits multiple times by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#3983 - Add config option to disable switching tabs with panel jump keys (and disable by default) by [@​hgreenstein](https://github.com/hgreenstein) in jesseduffield/lazygit#3927 - We jumped the gun on this change in the last release: having the number key both select a panel and switch tabs was bad for muscle memory so it's that behaviour is now disabled by default. - Add new filter to only show tracked files in Files panel by [@​veremenko-y](https://github.com/veremenko-y) in jesseduffield/lazygit#4024 - Allow DiffContextSize to be decreased to zero by [@​LuxxxLucy](https://github.com/LuxxxLucy) in jesseduffield/lazygit#4050 - Allow user to select remote and branch when creating a MR by [@​moha-gh](https://github.com/moha-gh) in jesseduffield/lazygit#1889 - Delete range selection of branches by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4073 - Show the number of lines changed per file in working file tree view by [@​johannaschwarz](https://github.com/johannaschwarz) in jesseduffield/lazygit#4015 - Drop merge commits by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4094 - Wrap lines in staging view by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4098 - Allow to switch branches in Commit View ([#​4115](jesseduffield/lazygit#4115)) by [@​seflue](https://github.com/seflue) in jesseduffield/lazygit#4117 - Allow on prem Azure DevOps Server pull request by [@​waynebowie99](https://github.com/waynebowie99) in jesseduffield/lazygit#3954 - Add screen-mode command line argument by [@​alewis001](https://github.com/alewis001) in jesseduffield/lazygit#4103 - Default to half-screen mode when opening with certain CLI args by [@​jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4141 - Show the alt-enter keybinding at bottom of commit description view by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4136 - Add number of commits to cherry-pick confirmation prompt by [@​brandondong](https://github.com/brandondong) in jesseduffield/lazygit#4158 ##### Fixes 🔧 - Fix copying commit author to clipboard by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#3936 - Fix merge conflict resolution when file doesn't end with a LF by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#3976 - Fix file icons by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#3975 - Fix non-sticky range select after clicking in staging view by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#3998 - Fix scroll position when entering staging view by clicking in the main view by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#3992 - Fix mouse wheel scrolling of custom patch view by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4089 - Improve editing a commit by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4090 - Use custom context size in range diff by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4082 - commits panel: add missing default sort order by [@​phanirithvij](https://github.com/phanirithvij) in jesseduffield/lazygit#4097 - Fix issues with opening links and files using WSL by [@​bottino](https://github.com/bottino) in jesseduffield/lazygit#3850 - Fix moving a commit across a branch boundary in a stack of branches by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4096 - Don't preserve commit message when it's unchanged from initial message by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4110 - Fix hang when returning from shell command by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4126 - Prevent killing of unrelated processes on windows by [@​jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4137 - Add worktree option to fast forwarding operation by [@​john-mutuma](https://github.com/john-mutuma) in jesseduffield/lazygit#4051 - Don't show keybindings option in bottom line when panel is open by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4143 - Fix reset/rebase to upstream by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4151 - Avoid blank line at end of view by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4152 - Adjust line number for working copy when editing a line by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4119 - Fix `micro` editor preset by [@​kytta](https://github.com/kytta) in jesseduffield/lazygit#4156 - Use interactive shell for running shell commands only if shell is bash or zsh by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4159 ##### Maintenance ⚙️ - Add performance improvements section to release notes by [@​jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#3922 - ci: update `upload-artifact` and `download-artifact` actions to v4 by [@​Juneezee](https://github.com/Juneezee) in jesseduffield/lazygit#4063 - Let schema/config.json end with a line feed by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4092 - Saner view geometry by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4085 - Cleanup background fetch by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4084 - remove duplicate secondary MouseWheelUp keybind by [@​samueldominguez](https://github.com/samueldominguez) in jesseduffield/lazygit#4120 - enhancement: Use HEX colors on file icons instead of C256 colors by [@​hasecilu](https://github.com/hasecilu) in jesseduffield/lazygit#4029 - chore: use errors.New to replace fmt.Errorf with no parameters by [@​RiceChuan](https://github.com/RiceChuan) in jesseduffield/lazygit#4107 - Fix typos by [@​NathanBaulch](https://github.com/NathanBaulch) in jesseduffield/lazygit#3920 - Bump crypto and net packages by [@​jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4144 - Tweak file icons by [@​jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4145 - Standardise on 'screen mode' naming convention by [@​jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4142 ##### Docs 📖 - Fix installation for Ubuntu in README.md by [@​shaobosong](https://github.com/shaobosong) in jesseduffield/lazygit#4031 - Fixes to lazygit Ubuntu install instructions in README.md by [@​wrecklass](https://github.com/wrecklass) in jesseduffield/lazygit#3970 - Fix typos by [@​skoch13](https://github.com/skoch13) in jesseduffield/lazygit#4121 - Add vision and design principles doc by [@​jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4053 - docs: Stylize and correct the NixOS section in README.md by [@​wadsaek](https://github.com/wadsaek) in jesseduffield/lazygit#4135 - Update chinese translation for pull requests by [@​jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4140 - Set repology table to 3 columns by [@​hasecilu](https://github.com/hasecilu) in jesseduffield/lazygit#4138 - Update instructions for using OSC52 with tmux by [@​EliasA5](https://github.com/EliasA5) in jesseduffield/lazygit#3597 - Update docs to describe use of custom commands without keybindings by [@​a-jentleman](https://github.com/a-jentleman) in jesseduffield/lazygit#3846 - documentation - describe os.openLink by [@​smangels](https://github.com/smangels) in jesseduffield/lazygit#3094 - Clarify commit message prefix mechanics by [@​zeromask1337](https://github.com/zeromask1337) in jesseduffield/lazygit#4114 #### New Contributors - [@​shaobosong](https://github.com/shaobosong) made their first contribution in jesseduffield/lazygit#4031 - [@​hgreenstein](https://github.com/hgreenstein) made their first contribution in jesseduffield/lazygit#3927 - [@​wrecklass](https://github.com/wrecklass) made their first contribution in jesseduffield/lazygit#3970 - [@​veremenko-y](https://github.com/veremenko-y) made their first contribution in jesseduffield/lazygit#4024 - [@​LuxxxLucy](https://github.com/LuxxxLucy) made their first contribution in jesseduffield/lazygit#4050 - [@​phanirithvij](https://github.com/phanirithvij) made their first contribution in jesseduffield/lazygit#4097 - [@​bottino](https://github.com/bottino) made their first contribution in jesseduffield/lazygit#3850 - [@​johannaschwarz](https://github.com/johannaschwarz) made their first contribution in jesseduffield/lazygit#4015 - [@​samueldominguez](https://github.com/samueldominguez) made their first contribution in jesseduffield/lazygit#4120 - [@​skoch13](https://github.com/skoch13) made their first contribution in jesseduffield/lazygit#4121 - [@​wadsaek](https://github.com/wadsaek) made their first contribution in jesseduffield/lazygit#4135 - [@​seflue](https://github.com/seflue) made their first contribution in jesseduffield/lazygit#4117 - [@​waynebowie99](https://github.com/waynebowie99) made their first contribution in jesseduffield/lazygit#3954 - [@​EliasA5](https://github.com/EliasA5) made their first contribution in jesseduffield/lazygit#3597 - [@​alewis001](https://github.com/alewis001) made their first contribution in jesseduffield/lazygit#4103 - [@​a-jentleman](https://github.com/a-jentleman) made their first contribution in jesseduffield/lazygit#3846 - [@​john-mutuma](https://github.com/john-mutuma) made their first contribution in jesseduffield/lazygit#4051 - [@​RiceChuan](https://github.com/RiceChuan) made their first contribution in jesseduffield/lazygit#4107 - [@​NathanBaulch](https://github.com/NathanBaulch) made their first contribution in jesseduffield/lazygit#3920 **Full Changelog**: jesseduffield/lazygit@v0.44.1...v0.45.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xMzcuMSIsInVwZGF0ZWRJblZlciI6IjM5LjEzNy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
This allows range-selecting multiple branches and deleting them all at once. We allow deleting remote branches (or local and remote branches) as long as all selected branches have one.
We show the warning about force-deleting as soon as at least one of the selected branches is not fully merged.
go generate ./...
)