Skip to main content

Tool for getting version info from git history

Project description

A simple tool for extracting version information from git tags and formatting it with optional post-release commit info.

Version tags can optionally use a v prefix, and can include pre-release versions.

Installation

Install from PyPI:

pip install vergit

Usage

Full usage:

vergit [-h] [--format {long,short,default,json}] [path]

The path can be omitted and defaults to the current directory.

There are several different formats which can be used:

  • long Always include the git revision info. which is one commit newer than the 1.0.0 release.

  • short Never include the git revision info, only the release version.

  • default Uses the long format if on a pre-release or there are commits after the release, otherwise the short format.

  • json Output JSON data describing the version.

Examples

If the current commit is tagged with v1.0.0:

$ vergit
1.0.0

$ vergit --format short
1.0.0

$ vergit --format long
1.0.0+git-0-123abcd

$ vergit --format json
{"version": "1.0.0", "git": "+git-0-123abcd", "gitn": "0", "gitsha": "123abcd", "pre_release": false}

If the commit before the current is tagged with 1.0.0:

$ vergit
1.0.0+git-1-123abcd

$ vergit --format short
1.0.0

$ vergit --format long
1.0.0+git-0-123abcd

$ vergit --format json
{"version": "1.0.0", "git": "+git-1-123abcd", "gitn": "1", "gitsha": "123abcd", "pre_release": false}

If the current commit is tagged with v1.0.0rc1:

$ vergit
1.0.0rc1+git-0-123abcd

$ vergit --format short
1.0.0rc1

$ vergit --format long
1.0.0rc1+git-0-123abcd

$ vergit --format json
{"version": "1.0.0rc1", "git": "+git-0-123abcd", "gitn": "0", "gitsha": "123abcd", "pre_release": true}

Project details


Download files

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

Source Distribution

vergit-1.0.1.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file vergit-1.0.1.tar.gz.

File metadata

  • Download URL: vergit-1.0.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for vergit-1.0.1.tar.gz
Algorithm Hash digest
SHA256 bcf2eaeaa358b9e617950b38224c2a77652746109ede2b41f239ad10e8bf0f67
MD5 a2c859d27d29d37580202be27a058f2a
BLAKE2b-256 f07931412ed21c6b7f79b67948841fde02517ce552015cf0872bff579becebe7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page