improve quality

This commit is contained in:
cclecle
2023-03-18 01:39:25 +00:00
parent bce35f0a60
commit df74016945

View File

@@ -152,10 +152,10 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
if len(res)==1:
res = _exec(f"git describe --tags {res[0]}")
if len(res)==0:
if len(res)==0:
raise cls.tagNotFound("no tag found in commit history")
if len(res)!=1:
raise cls.moreThanOneTag("multiple tags on same commit is unsupported")
if len(res)!=1:
raise cls.moreThanOneTag("multiple tags on same commit is unsupported")
return res[0]
@classmethod
@@ -187,7 +187,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
r"(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$",
"regex_preversion_num": r"(?:\.)(?P<num>(?:\d+(?!\w))+)",
"regex_build_num" : r"(?:\.)(?P<num>(?:\d+(?!\w))+)"
},
"PEP440" : { "regex" : packaging_VERSION_PATTERN,
"Auto" : None
@@ -224,7 +224,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
raw:str = "0.1.0"
def __init__(self,version_std,major=0,minor=1,patch=0,pre_count=0,post_count=0,raw="0.1.0"): #pylint: disable=R0913
self.version_std = version_std
self.version_std = version_std
self.major = major
self.minor = minor
self.patch = patch
@@ -242,7 +242,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
Kwargs given bump_dev_strategy or the default one.
"""
BumpDevStrategy = cls.DefaultBumpDevStrategy
if (cls.__OptDict["bump_dev_strategy"] in kwargs):
if cls.__OptDict["bump_dev_strategy"] in kwargs:
if kwargs[cls.__OptDict["bump_dev_strategy"]] in cls.BumpDevStrategys:
BumpDevStrategy = kwargs[cls.__OptDict["bump_dev_strategy"]]
else:
@@ -259,7 +259,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
Kwargs given bump_type or the default one.
"""
BumpType = cls.DefaultBumpType
if (cls.__OptDict["bump_type"] in kwargs):
if cls.__OptDict["bump_type"] in kwargs:
if kwargs[cls.__OptDict["bump_type"]] in cls.BumpTypes:
BumpType = kwargs[cls.__OptDict["bump_type"]]
else:
@@ -314,6 +314,11 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
return _v
def doFormatVersion(self,**kwargs):
"""
output a formated version string
Return:
formated version string
"""
return gitversionhelper.version.doFormatVersion(self,**kwargs)
@classmethod
@@ -335,6 +340,15 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
@classmethod
def getCurrentVersion(cls,**kwargs) -> Union[str,MetaVersion]:
"""
get the current version or bump depending of repository state
Kwargs:
version_std(str): the given version_std (can be None)
same_branch(bool): force searching only in the same branch
formated_output(bool) : output a formated version string
Return:
the last version
"""
if gitversionhelper.repository.isDirty() is not False:
raise gitversionhelper.repository.repositoryDirty( "The repository is dirty and a current version" \
" can not be generated.")
@@ -355,7 +369,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
@classmethod
def getLastVersion(cls,**kwargs) -> Union[str,MetaVersion]: # pylint: disable=R0914, R0912, R0915
"""
bump the last version from tags
get the last version from tags
Kwargs:
version_std(str): the given version_std (can be None)
same_branch(bool): force searching only in the same branch
@@ -365,9 +379,9 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
"""
VersionStd = cls._getVersionStd(**kwargs)
bAutoVersionStd = False
bAutoVersionStd = False
if VersionStd == "Auto":
bAutoVersionStd = True
bAutoVersionStd = True
lastTag=cls.MetaVersion.raw
cls.__versionReseted = False
@@ -377,7 +391,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
logging.warning('tag not found, reseting versionning')
cls.__versionReseted = True
bFound = False
bFound = False
if VersionStd == "SemVer" or (bAutoVersionStd is True) :
_r=re.compile(r"^\s*" + cls.VersionStds["SemVer"]["regex"] + r"\s*$", re.VERBOSE | \
re.IGNORECASE)
@@ -478,4 +492,4 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
minor=inputversion.minor, \
patch=patch, \
revpattern=revpattern, \
revcount=revcount)
revcount=revcount)