Skip to main content

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.

  • 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}

Metadata

Release files for vergit 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vergit 1.0.2
File Size Uploaded
vergit-1.0.2.tar.gz 3.2 kB Details

Release files / vergit-1.0.2.tar.gz

Download URL vergit-1.0.2.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ea82a4d6057d4891a4b16e0881bd756ceea2b66253edc05dd619450f88a5ff31
BLAKE2b-256 checksum
How to use checksums
d8dc2ef077a97a05633bbe7a46b9cb4b87fbf994a9aaa52b44a8f1086d20951f
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.0.2 This release

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page