ChiliProject is not maintained anymore. Please be advised that there will be no more updates.

We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.

What is the best way to setup git such that a push can only be completed if every commit points to a valid ticket number?

Added by Shoan Motwani at 2012-02-06 02:44 pm

I would like to mandate more history tracking by forcing developers to only commit against a valid ticket. Is there a hook for this? I remember there used to be such a feature in Trac for SVN.

Thanks in advance.


Replies (4)

RE: What is the best way to setup git such that a push can only be completed if every commit points to a valid ticket number? - Added by Pauli Price at 2012-02-13 10:18 pm

You want to write a pre-commit hook. In your hook you'll need to parse the commit message and confirm that it includes a valid ticket identifier.

See: http://book.git-scm.com/5_git_hooks.html

RE: What is the best way to setup git such that a push can only be completed if every commit points to a valid ticket number? - Added by Pauli Price at 2012-02-13 10:18 pm

You want to write a pre-commit hook. In your hook you'll need to parse the commit message and confirm that it includes a valid ticket identifier.

See: http://book.git-scm.com/5_git_hooks.html

RE: What is the best way to setup git such that a push can only be completed if every commit points to a valid ticket number? - Added by Shoan Motwani at 2012-02-14 06:51 am

Thanks for advice. How do I go about determining if the ticket is valid? All my projects are private. Is there an API that invoke from the hook to validate the ticket?

RE: What is the best way to setup git such that a push can only be completed if every commit points to a valid ticket number? - Added by Felix Schäfer at 2012-02-14 07:30 am

There's an API for tickets, you'd have to create a user that has access to all those projects though.

Another way would be to use a "ChiliProject script", i.e. a ruby script executed in the ChiliProject context. Your ChiliProject installation has a script/runner script you can use to execute ad hoc ruby code or even as a shebang, see it's help for more info.

(Quick usage example:

script/runner 'begin; status = 0 if Issue.find(123).present?; rescue ActiveRecord::RecordNotFound; status = 1; end; exit status'

This exits with status 0 if an issue with the ID 123 is present, 1 if not.)

(1-4/4)