Skip to content

Git Commit Hooks

Jeff Felchner edited this page Jan 12, 2018 · 3 revisions

Note: All of the hooks below are built into the excellent overcommit gem. There was no reason to re-invent the wheel here. The folks over at Brigade do an amazing job and stay on top of issues, pull requests and other support problems.

Chamber Security Pre-Commit Hook

When working with settings security, if a secure setting is ever accidentally committed to the repository, it's no longer secure. And when making commits, it's a definite possibility that a developer may forget that they should have secured a setting, only to type git push before they do.

You can enable it by creating an .overcommit.yml file and adding:

ChamberSecurity:
  enabled: true

Whenever you commit any of your settings files, the hook will confirm that all _secure_ settings have been encrypted. If they have not, the commit will abort.

Chamber Verification Pre-Commit Hook

When working with settings verification, it's important to remember to let the Approver know that settings have changed and that the current file signature will no longer match.

You can enable it by creating an .overcommit.yml file and adding:

ChamberVerification:
  enabled: true

Whenever you commit any of your settings files, the hook will warn the user that the signature no longer matches and that the Approver needs to be notified.

If you'd like to specify the name and email address of the Approver, you can add that to the configuration:

ChamberVerification:
  enabled:        true
  approver_name:  "Jeff Felchner"
  approver_email: "jeff@example.com"

Chamber Compare Pre-Commit Hook

One of the pain points that can arise from adding settings to your application is if you've set a new (required) item in development and test, so it works locally and the tests pass, but you've forgotten to set it in production (no, having a staging environment doesn't fully alleviate this issue).

Then, you deploy your app only to have it blow up, which sets your customers out with pitchforks for your head.

Fortunately Chamber provides an easy solution. Whenever you commit settings files, Chamber can automatically verify the settings of multiple different namespace sets to ensure that they're all consistent.

For example, it can take development, test and production and verify that all the keys that exist in one, exist in the other two. If that isn't the case, the hook will fail and the commit will abort.

You can enable it by creating an .overcommit.yml file and adding:

ChamberCompare:
  enabled: true

This hook has a couple of different additional options:

Name Description Example
namespaces This is an array of arrays of namespaces to compare to each other. Typically each inner array will only have one item (the environment) but if you wanted to do a more intensive comparison, you could. [['development'], ['test'], ['production']]
exclusions If any of these items are missing from one or more environments, it'll be ignored ['SMTP_DELIVERY_METHOD']
Clone this wiki locally