top | item 8586384

Show HN: GitCop – Automated Commit Message Validation for GitHub Pull Requests

55 points| Gazler | 11 years ago |gitcop.com | reply

27 comments

order
[+] akoeplinger|11 years ago|reply
Can the bot comment include an example of a good commit message?

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.

[+] Gazler|11 years ago|reply
This is a great idea, definitely something worth implementing. Thanks for the feedback.
[+] weavejester|11 years ago|reply
It's a very nice idea, but the validation rules are extremely limited.

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"
[+] Gazler|11 years ago|reply
I think doing it like that is a neat idea. Perhaps there could be an "advanced" page which is as you describe and the current method could be the "simple" version?
[+] eLobato|11 years ago|reply
This is quite cool, and actually something I'll propose to use at some http://github.com/theforeman repos.

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!
[+] Gazler|11 years ago|reply
Hi, thanks for the feedback, it would be great to be used by a project like Foreman!

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!
[+] Myrmornis|11 years ago|reply
After the PR is opened is too late to warn about commit messages. They can't be changed without a destructive push to the remote, which is generally a no-no for a public branch, and when using github, closes the PR automatically. The correct place to do this is, I believe, in the `commit-msg` hook: http://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
[+] iandanforth|11 years ago|reply
Slightly off topic - are there any good plugins/tools that remind you to commit frequently? I'd love something like this for sublime.
[+] akoeplinger|11 years ago|reply
Have you thought about opening this up for more than just commit messages?

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.

[+] Gazler|11 years ago|reply
Thanks for the ideas.

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.

[+] tokenrove|11 years ago|reply
I like the idea, but for projects that aren't open source, why not just mandate the use of a git commit-msg hook instead?
[+] Gazler|11 years ago|reply
A git hook would certainly work for this as you described and I would certainly encourage people to investigate that route if it is appropriate for them. http://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks

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.

[+] tjbiddle|11 years ago|reply
Looks clean, has plenty of features, and I love the pricing schema (Unlimited for open source projects - Always been a fan of this trend).

Great work!

[+] thestonefox|11 years ago|reply
What an awesome service, I'm signing up my dev team for this right now! Worth the money!
[+] Gazler|11 years ago|reply
Thanks for the feedback, I hope your dev team find it as valuable as you do.
[+] dmooney1|11 years ago|reply
I'd love it if you could make this work with Atlassian Stash behind a firewall.
[+] mindsocket|11 years ago|reply
Stash has a number of integration points where similar checks could be applied, the most similar to GitCop being a merge check. That said, a pre-receive hook would make a lot more sense.

Disclosure: I work for Atlassian

[+] Gazler|11 years ago|reply
I'm not too familiar with Atlassian Stash, I will have a search around and see how plausible it would be to integrate.
[+] jimmyboyb|11 years ago|reply
I have been looking for something like this
[+] warrenmcwin|11 years ago|reply
looks like Robocop has finally joined the Pull Police. nice job!