From 3fd9ab10492e83e229ed6162153a1d43a080f071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sun, 6 Feb 2022 15:09:49 +0100 Subject: [PATCH] move git version info --- .../versioning/version_info/version_info.py | 36 +----------------- PyTeX/format/git_version_info.py | 37 +++++++++++++++++++ 2 files changed, 39 insertions(+), 34 deletions(-) create mode 100644 PyTeX/format/git_version_info.py diff --git a/PyTeX/build/versioning/version_info/version_info.py b/PyTeX/build/versioning/version_info/version_info.py index a5de263..0aa4587 100644 --- a/PyTeX/build/versioning/version_info/version_info.py +++ b/PyTeX/build/versioning/version_info/version_info.py @@ -1,41 +1,9 @@ from typing import Optional + +from PyTeX.format.git_version_info import GitVersionInfo from .constants import * -class GitVersionInfo: - def __init__(self, dictionary: dict): - if not all( - x in dictionary.keys() for - x in [JSON_BRANCH, JSON_COMMIT_HASH] - ): - raise NotImplementedError - - self._dirty: bool = dictionary[JSON_DIRTY] - self._commit_hash: str = dictionary[JSON_COMMIT_HASH] - self._branch: Optional[str] = \ - dictionary[JSON_BRANCH] if JSON_BRANCH in dictionary.keys() \ - else None - self._version: Optional[str] = \ - dictionary[JSON_VERSION] if JSON_VERSION in dictionary.keys() \ - else None - - @property - def is_dirty(self) -> bool: - return self._dirty - - @property - def version(self) -> Optional[str]: - return self._version - - @property - def commit_hash(self) -> Optional[str]: - return self._commit_hash - - @property - def branch(self) -> Optional[str]: - return self._branch - - class FileVersionInfo: def __init__(self, dictionary: dict): if JSON_MD5_CHECKSUM not in dictionary.keys(): diff --git a/PyTeX/format/git_version_info.py b/PyTeX/format/git_version_info.py new file mode 100644 index 0000000..c39abb2 --- /dev/null +++ b/PyTeX/format/git_version_info.py @@ -0,0 +1,37 @@ +from typing import Optional + +from PyTeX.build.versioning.version_info.constants import JSON_BRANCH, JSON_COMMIT_HASH, JSON_DIRTY, JSON_VERSION + + +class GitVersionInfo: + def __init__(self, dictionary: dict): + if not all( + x in dictionary.keys() for + x in [JSON_BRANCH, JSON_COMMIT_HASH] + ): + raise NotImplementedError + + self._dirty: bool = dictionary[JSON_DIRTY] + self._commit_hash: str = dictionary[JSON_COMMIT_HASH] + self._branch: Optional[str] = \ + dictionary[JSON_BRANCH] if JSON_BRANCH in dictionary.keys() \ + else None + self._version: Optional[str] = \ + dictionary[JSON_VERSION] if JSON_VERSION in dictionary.keys() \ + else None + + @property + def is_dirty(self) -> bool: + return self._dirty + + @property + def version(self) -> Optional[str]: + return self._version + + @property + def commit_hash(self) -> Optional[str]: + return self._commit_hash + + @property + def branch(self) -> Optional[str]: + return self._branch \ No newline at end of file