Compare commits

...

2 Commits

Author SHA1 Message Date
cclecle
792666c6ec fix: rename hash -> commit_hash to avoid using builtin symbol 2023-03-19 10:17:58 +00:00
cclecle
2951e70c47 fix: escapes git strings options 2023-03-19 10:15:23 +00:00

View File

@@ -139,7 +139,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
the commit message
"""
current_commit_id=cls.getLast(**kwargs)
tag_commit_id=cls.getFromTag(tag,**kwargs)
tag_commit_id=cls.getFromTag(tag)
if ((cls.__OptDict["same_branch"] in kwargs) and (kwargs[cls.__OptDict["same_branch"]] is True)):
commits = _exec(f"git rev-list --first-parent --ancestry-path {tag_commit_id}..{current_commit_id}")
@@ -147,7 +147,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
commits = _exec(f"git rev-list --ancestry-path {tag_commit_id}..{current_commit_id}")
result=[]
for commit in commits:
result.append(cls.getMessage(commit,**kwargs))
result.append(cls.getMessage(commit))
if ((cls.__OptDict["merged_output"] in kwargs) and (kwargs[cls.__OptDict["merged_output"]] is True)):
print("JOIN")
@@ -155,16 +155,16 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
return result
@classmethod
def getMessage(cls, hash:str) -> str:
def getMessage(cls, commit_hash:str) -> str:
"""
retrieve a commit message from repository
Args:
hash: id of the commit
commit_hash: id of the commit
Returns:
the commit message
"""
try:
res=_exec(f"git log -z --pretty=tformat:%B%-C() -n 1 {hash}",None,True).rstrip('\x00')
res=_exec(f"git log -z --pretty=\"tformat:%B%-C()\" -n 1 {commit_hash}",None,True).rstrip('\x00')
except gitversionhelper.unknownGITFatalError as _e:
raise cls.commitNotFound("no commit found in commit history") from _e
@@ -202,7 +202,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
except gitversionhelper.unknownGITFatalError as _e:
raise cls.commitNotFound("no commit found in commit history") from _e
else:
res = _exec("git for-each-ref --sort=-committerdate refs/heads/ --count 1 --format=%(objectname)")
res = _exec("git for-each-ref --sort=-committerdate refs/heads/ --count 1 --format=\"%(objectname)\"")
if len(res)==0:
raise cls.commitNotFound("no commit found in commit history")