vcsinfo
Python abstraction layer for getting info from VCSes sych as git.
Requirements
- Python 3.5 or newer
- Git 1.8.5 or newer
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
# Shows basic information such as the SHA1 hash and the symbolic reference
print(str(version))
# 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