diff --git a/README.rst b/README.rst index 8c5b2bc..fb24945 100644 --- a/README.rst +++ b/README.rst @@ -4,9 +4,9 @@ Map git commits to auto-versions and vice versa Features -------- -- Calculated versions are Debian compatible. +- Calculated versions are Debian compatible and version sort as expected. -- Supports named versions (e.g., "1.0") based on signed tags +- Supports named versions (e.g., "1.0") based on annoted/signed tags. - Automatically calculates named version numbers for untagged commits that follow a tagged commit (e.g., "1.0+1+g873bc99") @@ -14,6 +14,8 @@ Features - Supports anonymous date based versions (e.g., "0+2015.2.13+09.03.03+38a2eec6") for untagged commits that precede any signed tags. + + Usage ----- @@ -130,4 +132,3 @@ Notes: * Untagged autoversion should always be evaluated by Debian package management as earlier than a tagged autoversion - diff --git a/autoversion_lib/__init__.py b/autoversion_lib/__init__.py index 4c053a3..7c94055 100644 --- a/autoversion_lib/__init__.py +++ b/autoversion_lib/__init__.py @@ -8,14 +8,32 @@ # option) any later version. import re - +import os from time import gmtime from calendar import timegm import urllib.parse +import logging from typing import Optional, Generator from gitwrapper import Git, GitError # type: ignore +logger = logging.getLogger('autoversion') +level = os.getenv('AUTOVERSION_LOG_LEVEL', '').lower() +if level == 'info': + loglevel = logging.INFO +elif level == 'debug': + loglevel = logging.DEBUG +elif level in ('', 'warn', 'warning'): + loglevel = logging.WARNING +elif level in ('err', 'error', 'fatal'): + loglevel = logging.ERROR +else: + loglevel = logging.WARNING +logging.basicConfig( + format='%(asctime)s - [%(levelname)-7s] ' + + '%(filename)s:%(lineno)d %(message)s', + level=loglevel) + class AutoverError(Exception): pass @@ -175,9 +193,11 @@ def __init__(self, path: str, precache: bool = False): precache_commits=precache_commits) self.git = git + logger.debug(f'Inititialized Autoversion - self: {self}') def _resolve_ambigious_shortcommit( self, short: str, timestamp: int) -> str: + logger.debug(f'Resolving ambiguous short commit: {short} ({timestamp=})') if not self.timestamps.precache: self.timestamps = Timestamps(self.git, precache=True) diff --git a/debian/control b/debian/control index 2e30dd6..8715fa7 100644 --- a/debian/control +++ b/debian/control @@ -11,7 +11,7 @@ Standards-Version: 4.0.0 X-Python-Version: >= 3.5 Package: autoversion -Architecture: all +Architecture: any Depends: git (>= 1:2.1.4), ${misc:Depends},