git-delete-merged-branches icon indicating copy to clipboard operation
git-delete-merged-branches copied to clipboard

Support exclude-regex

Open mcico opened this issue 2 years ago • 2 comments

Hello,

I recently switched to use git-delete-merged-branches (from git-trim). I like the approach of git-dmb, in particular the safety net we get.

In #52 the support of --include-regex was added. I would appreciate the same feature, but for the exclusion.

In our company we work on many git repository (on many different projects), while we all follow a common branch naming pattern, where we for example use release/<version> as a pattern for branches we must keep for a longer time around.

Based on that I would like to add an --exclude-pattern which skips all branches of the given pattern, in my case release/.* from deletion. While I could add entries to the git config with a few bash commands, I would have to do that for each and every git repository and update it regularly, whereas with the pattern I could just add it to my global git config and be sure that such branches are not deleted by accident.

cheers & thanks, marco

mcico avatar Feb 20 '23 13:02 mcico

Hi @mcico,

I'll just do a quick braindump here so you have a reply quicker, if that's okay:

  • I'm glad you consider the safety net helpful.
  • I'd be curious to learn more about what made you look for alternatives to git-trim and how you found git-delete-merged-branches. If you feel like elaborating here or via e-mail (see profile) I wold be curious to learn more for sure.
  • --include-regex has no Git config equivalent right now and is not easy to fit into the --configure dialog. Pattern include and exclude is a bit off the road compared to the rest of the feature set.
  • Once we have both includes and excludes, order and multiple instances start to matter, e.g. think of include a*, exclude aa*, include aaa*.

Let me digest this more, best, Sebastian

hartwork avatar Feb 20 '23 14:02 hartwork

Hoi @hartwork,

I'd be curious to learn more about what made you look for alternatives to git-trim and how you found git-delete-merged-branches. If you feel like elaborating here or via e-mail (see profile) I wold be curious to learn more for sure.

At the company I we work with older linux distributions (red hat 7 and 8) where I installed git-trim through linuxbrew. Unfortunately linuxbrew started to break on red hat 7 and 8, which is why I was looking for another solution. I think I came accross git-dmb through googling.

--include-regex has no Git config equivalent right now and is not easy to fit into the --configure dialog. Pattern include and exclude is a bit off the road compared to the rest of the feature set.

This is what I arealized as well, which is why I raised the request. When working with dozens of repositories, it would be nice to configure the default behaviour through a global config (e.g. in .gitconfig) or even in a separate configuration file. So I am looking for a way to automate cleaning up multiple repositories.

Once we have both includes and excludes, order and multiple instances start to matter, e.g. think of include a*, exclude aa*, include aaa*.

I understand that, I would expect that safety should win an din case of doubt to not delete a branch. Which means if a pattern would be used to exclude a branch it should win over a pattern that would include the same branch.

cheers & thanks marco

mcico avatar Mar 04 '23 10:03 mcico