hartwork / git-delete-merged-branches

:fire: Command-line tool to delete merged Git branches
https://pypi.org/project/git-delete-merged-branches/
GNU General Public License v3.0
878 stars 15 forks source link

Support exclude-regex #120

Open mcico opened 1 year ago

mcico commented 1 year ago

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

hartwork commented 1 year ago

Hi @mcico,

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

Let me digest this more, best, Sebastian

mcico commented 1 year ago

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