Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ 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")

- Supports anonymous date based versions (e.g.,
"0+2015.2.13+09.03.03+38a2eec6") for untagged commits that precede any
signed tags.



Usage
-----
Expand Down Expand Up @@ -130,4 +132,3 @@ Notes:

* Untagged autoversion should always be evaluated by Debian package
management as earlier than a tagged autoversion

22 changes: 21 additions & 1 deletion autoversion_lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down