Skip to content
Snippets Groups Projects

vcsinfo

Python abstraction layer for getting info from VCSes sych as git.

Requirements

  • Python 3.5 or newer
  • Git 1.8.5 or newer

Installation

$ pip install git+https://gitlab.astro-wise.org/omegacen/vcsinfo.git

Usage

You will first need instantiate a Repository instance. The preferred way to do this is via the factory method:

from vcsinfo.factory import build

repo = build('/path/to/my/git/repo')

The repo object can then be queried for info:

version = repo.current_version

# Returns a PEP 440 version identifier (can be used for logging or build numbers):
version.version_id

# Check if a newer version exists:
newest = version.newest(branch='master')
if newest.date > version.date:
    pass # or do something

# Check if a newer version exists for a given file:
last_change = version.newest(branch='master').last_change_on('relative/path/to/file')
if last_change is not None and last_change.date > version.date:
    pass # or do something