diff options
author | Robert Westman <robert@byteflux.io> | 2021-06-03 10:21:50 +0200 |
---|---|---|
committer | Robert Westman <robert@byteflux.io> | 2021-06-03 10:21:50 +0200 |
commit | abf9373865c319d2f1aaf188feef900bb8ebf933 (patch) | |
tree | 6750ac5eaba2af7e6e5b02764d2615039abc9d56 /git/repo/base.py | |
parent | 057514e85bc99754e08d45385bf316920963adf9 (diff) | |
download | gitpython-abf9373865c319d2f1aaf188feef900bb8ebf933.tar.gz |
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 (...)
Diffstat (limited to 'git/repo/base.py')
-rw-r--r-- | git/repo/base.py | 13 |
1 files changed, 12 insertions, 1 deletions
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 |