Telling users that "Commits must be in the following format: %{type}(%{scope}): %{description}" requires them to mentally parse and figure out what this means. Giving an example along the lines of "perf(backend): optimized db access" would make this easier.
Perhaps I'm wrong, but all of the rule options on the site look like they could have been implemented via regular expressions. Given the technical expertise of your intended customers, why not allow them to set a list of rules in the format: [regex, error-message], e.g.
"^.{0,50}\n" "The subject should be 50 characters or under"
"^.+\n(.{0,72}\n)*$" "The body should have lines of 72 characters or under"
"^\p{Upper}" "The subject should be capitalized"I didn't really understood the format rules, so if the author posted this, a help section would help. I try to enforce
'%(type) #xxxx(: | -) %{description}'
How would you do that? #xxxx is just an issue number, so it can be #23891, and after that I want a separator from the description, semi colon or hyphen are fine. Probably %{scope} can be used but I didn't really understand it from the inline help, sorry!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:
test string: "Fixes #1234: foo"
format: "%{type} #%{scope}: %{description}"
[type: "Fixes", scope: "1234", description: "foo"]
Using a hyphen as a separator: test string: "Fixes #1234 - foo"
format: "%{type} #%{scope} - %{description}"
[type: "Fixes", scope: "1234", description: "foo"]
I hope this makes sense, let me know if you get it working!Still, what does %{scope} actually catch? Anything that's not %{type}, %{description} or an explicit character?
Many projects need to check a number of things on PRs, e.g. enforce coding style, bugfix has a corresponding test, user signed the CLA, owner of %{scope} is notified for review, etc. That would obviously need a way to tie into external/custom tools as everybody validates these things differently.
I think there are several avenues that could be explored with this. I wanted to stay away from explicitly checking the code initially, as there are other tools aimed at that specific task, however there is no reason something like this couldn't be added into GitCop at a later date.
I had the idea of checking that the user exists in a list of users by specifying a JSON list of users. This means that it could be used to check if a CLA has been signed, but there are other applications too. Does this seem like a reasonable way to do it?
I like the idea of ensuring a test has been added, not sure how to tackle it, but it is certainly worth keeping in mind.
Or maybe provide me with a Travis-like sandbox where I can run my checks with whatever linter/validator/custom code I want and report the results back?
Just fleshing out some ideas here :)
The goal for GitCop is to be fast and easy to set up in a way that integrates well into a GitHub pull request based flow.
Great work!
An example of the messages GitCop outputs can be seen at https://github.com/Gazler/gitcop-test/pull/2 if you are interested.
Disclosure: I work for Atlassian