Skip to content

Commit abf9373

Browse files
committed
Fixes resolving of tag parameter for repo.tag
I accessed private variables instead of adding getters, because other parts of the code do the same and I didn't know if there was a reason for it. E.g.: remote.py line 409: (...) RemoteReference._common_path_default (...)
1 parent 057514e commit abf9373

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

git/repo/base.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,18 @@ def tags(self) -> 'IterableList':
402402
def tag(self, path: PathLike) -> TagReference:
403403
""":return: TagReference Object, reference pointing to a Commit or Tag
404404
:param path: path to the tag reference, i.e. 0.1.5 or tags/0.1.5 """
405-
return TagReference(self, path)
405+
full_path = self._to_full_tag_path(path)
406+
return TagReference(self, full_path)
407+
408+
@staticmethod
409+
def _to_full_tag_path(path: PathLike):
410+
if path.startswith(TagReference._common_path_default + '/'):
411+
return path
412+
if path.startswith(TagReference._common_default + '/'):
413+
return Reference._common_path_default + '/' + path
414+
else:
415+
return TagReference._common_path_default + '/' + path
416+
406417

407418
def create_head(self, path: PathLike, commit: str = 'HEAD',
408419
force: bool = False, logmsg: Optional[str] = None

0 commit comments

Comments
 (0)