From abf9373865c319d2f1aaf188feef900bb8ebf933 Mon Sep 17 00:00:00 2001 From: Robert Westman Date: Thu, 3 Jun 2021 10:21:50 +0200 Subject: 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 (...) --- git/repo/base.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'git') diff --git a/git/repo/base.py b/git/repo/base.py index e23ebb1a..540a5fe3 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -402,7 +402,18 @@ class Repo(object): def tag(self, path: PathLike) -> TagReference: """:return: TagReference Object, reference pointing to a Commit or Tag :param path: path to the tag reference, i.e. 0.1.5 or tags/0.1.5 """ - return TagReference(self, path) + full_path = self._to_full_tag_path(path) + return TagReference(self, full_path) + + @staticmethod + def _to_full_tag_path(path: PathLike): + if path.startswith(TagReference._common_path_default + '/'): + return path + if path.startswith(TagReference._common_default + '/'): + return Reference._common_path_default + '/' + path + else: + return TagReference._common_path_default + '/' + path + def create_head(self, path: PathLike, commit: str = 'HEAD', force: bool = False, logmsg: Optional[str] = None -- cgit v1.2.1