Re:Show HN: GitCop – Automated Commit Message Validation for...
by eLobato on Monday November 10, 2014 @06:13PM
(#8587252)
Interesting, that makes sense. I'll check if the rest of the team would be ok with forcing commits to use colon as a separator until that feature is added. :)
Still, what does %{scope} actually catch? Anything that's not %{type}, %{description} or an explicit character?
Re:Show HN: GitCop – Automated Commit Message Validation for...
by Gazler on Monday November 10, 2014 @06:19PM
(#8587296)
Glad it made sense!
So the match is exact between the non %{..} characters. The idea for scope is the context of the commit, in my libraries I use the name of the class as the scope.
For example with the default format string:
test string: "fix(User): ensure email address is required"
format: "%{type}(%{scope}): %{description}"
[type: "fix", scope: "User", description: "ensure email address is required"]
So any literal characters are matched exactly and anything inside the capturing %{...} is assigned to that variable.This does fall over in the following case:
"fix():(User): ensure email address is required"
"%{type}(%{scope}): %{description}"
[type: "fix", scope: "):(User", description: "ensure email address is required"]
It is certainly a candidate for improvement in the future.
Currently the string for the format only allows the 3 defined variables, type, scope and description. I have been using this style at https://github.com/Gazler/changex/commits/master to give you an idea of how it works.
I was concerned that the format string might be a little weird to get from the help. I will try and clear this up a bit.
I have attempted to build the string that you requested, currently an or separator is not supported, but I can take a look at adding it in.
Here are the format strings that I think match your use case. Using a colon as a separator:
Using a hyphen as a separator: I hope this makes sense, let me know if you get it working!