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

Delete range selection of branches #4073

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

stefanhaller
Copy link
Collaborator

@stefanhaller stefanhaller commented Nov 24, 2024

  • PR Description

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.

  • Please check if the PR fulfills these requirements
  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

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.
@stefanhaller stefanhaller added the enhancement New feature or request label Nov 24, 2024
Copy link

codacy-production bot commented Nov 24, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for c3cf48c1 97.81%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (c3cf48c) Report Missing Report Missing Report Missing
Head commit (99e4112) 51050 44036 86.26%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4073) 319 312 97.81%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@stefanhaller stefanhaller mentioned this pull request Nov 24, 2024
7 tasks
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.
Copy link

@rafgugi rafgugi left a 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)
}
Copy link

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.

Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants