@@ -25,6 +25,7 @@ repository (but unlike regular Git hooks, are stored in source control).
25
25
* [ Configuration] ( #configuration )
26
26
* [ Hooks] ( #hooks )
27
27
* [ Hook Categories] ( #hook-categories )
28
+ * [ Gemfile] ( #gemfile )
28
29
* [ Plugin Directory] ( #plugin-directory )
29
30
* [ Signature Verification] ( #signature-verification )
30
31
* [ Built-In Hooks] ( #built-in-hooks )
@@ -61,6 +62,10 @@ Depending on the hooks you enable/disable for your repository, you'll need to
61
62
ensure your development environment already has those dependencies installed.
62
63
Most hooks will display a warning if a required executable isn't available.
63
64
65
+ If you are using Bundler to manage your Ruby gem dependencies, you'll likely
66
+ want to use the [ ` gemfile ` ] ( #gemfile ) option to control which gem versions are
67
+ available during your hook runs.
68
+
64
69
## Installation
65
70
66
71
` overcommit ` is installed via [ RubyGems] ( https://rubygems.org/ ) :
@@ -239,6 +244,44 @@ hooks.
239
244
Again, you can consult the [default configuration](config/default.yml) for
240
245
detailed examples of how the `ALL` hook can be used.
241
246
247
+ # ## Gemfile
248
+
249
+ You may want to enforce the version of Overcommit or other gems that you use in
250
+ your git hooks. This can be done by specifying the `gemfile` option in your
251
+ ` .overcommit.yml` .
252
+
253
+ The `gemfile` option tells Overcommit to load the specified file with
254
+ [Bundler](http://bundler.io/), the standard gem dependency manager for Ruby.
255
+ This is useful if you would like to :
256
+
257
+ - Enforce a specific version of Overcommit to use for all hook runs
258
+ (or to use a version from the master branch that has not been released yet)
259
+ - Enforce a specific version or unreleased branch is used for a gem you want
260
+ to use in your git hooks
261
+
262
+ Loading a Bundler context necessarily adds a startup delay to your hook runs
263
+ as Bundler parses the specified `Gemfile` and checks that the dependencies are
264
+ satisfied. Thus for projects with many gems this can introduce a noticeable
265
+ delay.
266
+
267
+ The recommended workaround is to create a separate `Gemfile` in the root of
268
+ your repository (call it `.overcommit_gems.rb`), and include only the gems that
269
+ your Overcommit hooks need in order to run. Generate the associated lock file
270
+ by running :
271
+
272
+ ` ` ` bash
273
+ bundle install --gemfile=.overcommit_gems.rb
274
+ ` ` `
275
+
276
+ ...and commit `.overcommit_gems.rb` and the resulting
277
+ ` .overcommit_gems.rb.lock` file to your repository. Set your `gemfile` option
278
+ to `.overcommit_gems.rb`, and you're all set.
279
+
280
+ Using a smaller Gemfile containing only the gems used by your Overcommit hooks
281
+ significantly reduces the startup delay in your hook runs. It is thus the
282
+ recommended approach unless your project has a relatively small number of gems
283
+ in your `Gemfile`.
284
+
242
285
# ## Plugin Directory
243
286
244
287
You can change the directory that project-specific hooks are loaded from via
0 commit comments