Code Monkey home page Code Monkey logo

git-flow-hooks's Introduction

git-flow-hooks

Some useful hooks for git-flow (AVH Edition).

What does it do?

  • Prevent direct commits to the master branch.
  • Prevent merge marker commits.
  • Automatically bump versions when starting a release or hotfix. Versions are generated, written to file and committed.
  • Automatically specify tag messages.

Usage

Install

Clone this repository somewhere on your disk.

git clone [email protected]:jaspernbrouwer/git-flow-hooks.git

Whenever your read /path/to/git-flow-hooks, replace it with the actual path to your clone/working copy.

OS X

OS X doesn't support sort -V, which is used to sort git tags by version number, which in turn is needed to correctly bump versions.

On OS X you can install coreutils (using MacPorts or Homebrew), after which gsort -V can be used. If it's located at /opt/local/bin/gsort or /usr/local/bin/gsort we will pick it up automatically. Otherwise we fall back to /usr/bin/sort.

Optionally you can use the configuration option VERSION_SORT to point to a different command.

Activate

Initialize git-flow.

git flow init

It will ask you some questions, the last will be Hooks and filters directory?, which you can answer with /path/to/git-flow-hooks.

If you've already initialized git-flow, you can still set/change the path manually.

git config gitflow.path.hooks /path/to/git-flow-hooks

Update

Simply pull any updates from origin.

cd /path/to/git-flow-hooks
git pull

That's it, all your repositories that have git-flow initialized and use /path/to/git-flow-hooks as hooks and filters directory will be up-to-date.

Configuration

Copy the file /path/to/git-flow-hooks/modules/git-flow-hooks-config.sh.dist to .git/git-flow-hooks-config.sh and change whatever you like. This is completely optional.

git-flow (AVH Edition) has some useful configuration options too. See its wiki for a complete list. Or you can type git flow <command> [<subcommand>] --help.

Starting releases and hotfixes

If git flow release start and git flow hotfix start are run without a version, the version will be bumped automatically. Releases will be bumped at the minor level (1.2.3 becomes 1.3.0), hotfixes at the patch level (1.2.3 becomes 1.2.4). The hooks will look at the git tags to find the version to bump. If no tags are found, it looks for the version-file. If that isn't found, it assumes the current version is 0.0.0.

Alternatively you may use patch, minor and major as version. A bump of that level will take place.

If the commands are run with version, that version will be used (no bumping).

Automatic tag messages

If you want tag messages to be automated (you won't be bothered with your editor to specify it), use the following configuration options:

git config gitflow.hotfix.finish.message "Hotfix %tag%"
git config gitflow.release.finish.message "Release %tag%"

If you like, you can change the tag-placeholder (%tag% in the example above) in the git-flow-hooks configuration.

License

git-flow-hooks is published under The MIT License, see the LICENSE file.

Note that these hooks are built for git-flow (AVH Edition) by Peter van der Does, which has its own licenses.

The scripts for preventing master and merge marker commits are based on git-hooks by Sitebase.

git-flow-hooks's People

Contributors

jaspernbrouwer avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.