Build script

This commit is contained in:
caryoscelus 2024-04-04 22:15:34 +00:00
parent 3db5e10882
commit d09e1f8757
No known key found for this signature in database
GPG key ID: 254EDDB85B66CB1F
4 changed files with 61 additions and 3 deletions

View file

@ -10,22 +10,24 @@ import logging.handlers
import stat
import time
VERSION = "0.7.10+"
class Config:
def __init__(self, argv):
try:
from . import Build
except ImportError:
print('cannot find build')
from .util import Git
self.build_type = 'source'
self.branch = Git.branch() or 'unknown'
self.commit = Git.commit() or 'unknown'
self.version = VERSION
else:
self.build_type = Build.build_type
self.branch = Build.branch
self.commit = Build.commit
self.version = "0.7.10+"
self.version = Build.version or VERSION
self.version_full = f'{self.version} ({self.build_type} from {self.branch}-{self.commit})'
self.user_agent = "conservancy"
# for compatibility

View file

@ -48,7 +48,7 @@ def _gitted(f):
return lambda *args, **kwargs: None
@_gitted
def commit() -> str:
def commit() -> Optional[str]:
"""Returns git revision, possibly suffixed with -dirty"""
dirty = '-dirty' if _repo.is_dirty() else ''
return f'{_repo.head.commit}{dirty}'