https://github.com/brandonweiss/git-hookshot
Share git hooks in Ruby projects among all the collaborators automatically, without them having to do anything.
https://github.com/brandonweiss/git-hookshot
bundler git ruby
Last synced: 3 months ago
JSON representation
Share git hooks in Ruby projects among all the collaborators automatically, without them having to do anything.
- Host: GitHub
- URL: https://github.com/brandonweiss/git-hookshot
- Owner: brandonweiss
- License: mit
- Created: 2016-12-23T18:04:22.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-05T02:53:57.000Z (over 6 years ago)
- Last Synced: 2024-12-28T15:05:13.320Z (4 months ago)
- Topics: bundler, git, ruby
- Language: Ruby
- Homepage:
- Size: 14.6 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# git-hookshot
[](https://badge.fury.io/rb/git-hookshot) [](https://travis-ci.org/brandonweiss/git-hookshot)
git-hookshot allows you to share git hooks in Ruby projects among all the collaborators _automatically_, without them having to do anything. It automatically symLINKs them to the internal git hooks directory when installing gems with Bundler.
There are several other tools somewhat similar to this, but all of them require each collaborator working on a repository to run a specific command that generates the git hooks, and if they don’t then nothing happens. On a large project that can result in an untenable situation where unintentionally everyone has a different development experience.
npm has install hooks that can be easily hooked into it but Bundler and RubyGems don’t really. And yet a way has been found…
⚠️ **Caveat emptor** ⚠️
This entire gem runs on 🔮 dark magic 🔮. What it does isn’t intended to be possible to do, but it draws on the arcane power of defining gem install hooks _inside_ the gemspec in order to setup the git hooks during bundling and then dynamically overwrite the `post_install_message` in order to surface the explanatory output from the depths of where the gem install hook is called. I wouldn’t think too much about it. _If you gaze long into an abyss, the abyss also gazes into you._
## Installation
Add this line to your application’s Gemfile in the `development` group:
```ruby
gem "git-hookshot", group: [:development]
```*NB*: Right now there is a bug with installing from RubyGems.org—use the GitHub repository instead:
```ruby
gem "git-hookshot", github: "brandonweiss/git-hookshot", group: [:development]
```And then execute:
```shell
$ bundle
```Or install it yourself as:
```shell
$ gem install git-hookshot
```## Usage
git-hookshot is automatically run when bundling and will figure out what the right thing to do is given the state of your git hooks.
If you’re the first person to start using git-hookshot and you have no shared hooks, it will create empty shared hooks in `.hooks/` and symlink them to the internal git hook files at `.git/hooks/`. If you have existing internal git hooks they will be safely moved out of the way and a suffix of `.old` will be added to them.
You should add whatever logic you want to whatever hooks you want and then commit them to the repository.
When another collaborator pulls your changes which add git-hookshot and the shared git hooks Bundler will complain that there are new gems that need to be installed. When they bundle, git-hookshot will see the shared git hooks and create symlinks to the internal git hooks directory, enabling the shared git hooks. Collaborators don’t have to do anything extra—it just works.
git-hookshot can also be manually called with `bundle exec git-hookshot` if you need to re-generate a symlink or something.
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/brandonweiss/git-hookshot.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).