git_template
git_template copied to clipboard
Branch naming validation
I'm in love at first sight with this repo :heart:
My idea is to validate branch name against some pattern
so for example, as I personally mostly use git flow.
Plus I want to see ticket number as a part of the branch so I write this regex
^(feature|hotfix|bugfix|release)\/(ABC\-)\d{1,}\-[a-zA-Z]+
which will match this one
feature/ABC-3-asddas
Oh wow thanks that's humbling, really!
Regarding the branch naming validation, when should it be performed? On creation, before push, something else? Maybe it should be configurable?
I think, before push is the right one. Because if it's incorrect, you can easily change the name with
git checkout -b new-branch-name
I think it would be better to check on creation
git checkout -b new-branch-name
Or git branch -m
Anyway, both things can be done, and we can let the user choose on what event they want the check to happen, maybe?
@greg0ire yes.
I just don't want to over engeneer
Here is how it's done for make
in case you are wondering:
https://github.com/greg0ire/git_template/blob/820f947e371ea8025b65490c19ae20306b110425/template/hooks/make/pre-push#L6-L8
https://github.com/greg0ire/git_template/blob/820f947e371ea8025b65490c19ae20306b110425/template/hooks/make/pre-commit#L6-L8