Skip to main content

Enforce semver management in git repositories

Project description

Semver Git Hook

Install

Works with python 3.6+

First, install the tool using python ecosystem :

pip install --user  semver-git-hook

Use

Then set the hook in your current folder git repository :

semver-git-hook --init

That is all. Now on commit a release version type is asked interactively.

Prompt wich is new version for package on commit

Interactively select new version

On commit some version change will be saved in a .version file. It is automatically added to the current commit.

With this enabled you have your project version set in the .version file that it is possible to dynamically load to your dev environment versionning settings.

For exemple in python the setup.py can look like

# setup.py
with open('.version') as f:
    version = f.read()

setup(
    #...
    version=version,
    #...
)

and javascript

//That can be a version.js file that is triggered in .git/hooks/pre-commit
const f = require('fs')
const version = f.readFileSync('.version', 'utf-8')
const package = JSON.parse(f.readFileSync('package.json', 'utf-8'))
package.version = version
f.writeFileSync('package.json', JSON.stringify(package, null, 4))

Options

It is possible to change .version file location by setting a prefix in it's path. The file will be located at SEMVER_HOOK_PATH_PREFIX.version where SEMVER_HOOK_PATH_PREFIX is an environment variable.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for semver-git-hook, version 1.0.5
Filename, size File type Python version Upload date Hashes
Filename, size semver_git_hook-1.0.5-py2.py3-none-any.whl (4.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size semver-git-hook-1.0.5.tar.gz (3.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page