+
Skip to content

gildas/gitflow-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Flow hooks for GO

This repository contains git hooks for git flow to help deploy releases and hotfixes in my go repositories.

Pre-Requisites

The hooks from this repository will work only with git flow AVH Edition. The basic git-flow does not handle git hooks. Make sure to install the proper version!

The version of the target repository is assumed to follow the semver specifications.

Installation

First, you should git clone this project.

Then, from its folder, you just run the deployment script, pointing it at the target repository:

./hook-it /path/to/repo

On Windows:

.\hook-it.ps1 -Path /path/to/repo

The script will check if the repository is valid and has git-flow already, if not it complains.

Configuration

By default, the hooks will prevent you from:

  • committing anything to the master branch
  • committing anything that has unresolved merge conflicts

In case you do not want either of these features, you can turn them off with:

git config --bool gitflow.branch.allow-master-commit true
git config --bool gitflow.branch.allow-conflict-commit true

You can also change the prefix used to tag the new release/hotfix (default is none):

git config gitflow.prefix.versiontag v

Usage

Now, everything can be done in the target repository folder.

Starting a new release can be done simply:

git flow release start

The hooks will bump automatically the version in the code and the README.md, provided that:

  • in the code the version is a line like this:
    var version = '1.2.3'
    It does not matter which file contains the version, as long as there is only one.
  • in the README, the download badge and code references to id="my-extension" look like this:
    [![Download](https://path/to/badge?version=1.2.3)](https://path/to/software/1.2.3/whatever)
    <html>
      <script id="my-extension" src="https://path/to/software/1.2.3/stuff.js"></script>
      <script id="my-extension" src="https://path/to/software/stuff-1.2.3.js"></script>
    </html>

When the release is ready, simply finish it:

git flow release finish

Releases will bump the minor component of the semver version, by default.

Hotfixes work the very same way, although they modify the last number of the semver version (i.e. the patch):

git flow hotfix start
# ... work, work
git flow hotfix finish

Both releases and hotfixes allow overwriting the default version bump by providing a version to the start command:

  • major, minor, patch will bump the corresponding component of the semver version,
  • a semver version.

Examples:

git flow release start 12.3.4
git flow release start major

You do not need to repeat the version when finishing the release/hotfix.

If the repository has a "chart" folder, the scripts will update the "appVersion" accordingly as well. They will also bump the chart version according to the same rules used for the application version.

Hooks Update

Whenever there is an update to this repository, simply re-run the hook-it script to update the target repositories.

TODO

The hooks should log their work and maybe display some nicer progress.

Maybe having some in-repository code that would allow the hooks to update to the current version of this repository.

Acknowledgments

Thanks to Peter van der Does and Jasper N. Brouwer for their git flow hooks examples (resp. petervanderdoes/gitflow-avh, jaspernbrouwer/git-flow-hooks) that inspired me.

Of course, we wouldn't have any git flow without Vincent Driessen and his inspiring blog post A successful Git branching model about 10 years ago...

About

Git Flow hooks for my GO projects

Resources

License

Stars

Watchers

Forks

Packages

No packages published
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载