Skip to content

Fix orderdict, improve types #1304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 31, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update tag.py
  • Loading branch information
Yobmod authored Jul 31, 2021
commit b833eebece8d0c6cb1c79bc06e8ff9f26b994bb6
16 changes: 11 additions & 5 deletions git/refs/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

# typing ------------------------------------------------------------------

from typing import Any, Union, TYPE_CHECKING
from typing import Any, Type, Union, TYPE_CHECKING
from git.types import Commit_ish, PathLike

if TYPE_CHECKING:
from git.repo import Repo
from git.objects import Commit
from git.objects import TagObject
from git.refs import SymbolicReference


# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -68,7 +69,8 @@ def object(self) -> Commit_ish: # type: ignore[override]
return Reference._get_object(self)

@classmethod
def create(cls, repo: 'Repo', path: PathLike, reference: Union[Commit_ish, str] = 'HEAD',
def create(cls: Type['TagReference'], repo: 'Repo', path: PathLike,
reference: Union[str, 'SymbolicReference'] = 'HEAD',
logmsg: Union[str, None] = None,
force: bool = False, **kwargs: Any) -> 'TagReference':
"""Create a new tag reference.
Expand All @@ -78,7 +80,7 @@ def create(cls, repo: 'Repo', path: PathLike, reference: Union[Commit_ish, str]
The prefix refs/tags is implied
:param ref:
A reference to the object you want to tag. It can be a commit, tree or
A reference to the Object you want to tag. The Object can be a commit, tree or
blob.
:param logmsg:
Expand All @@ -98,7 +100,9 @@ def create(cls, repo: 'Repo', path: PathLike, reference: Union[Commit_ish, str]
Additional keyword arguments to be passed to git-tag
:return: A new TagReference"""
args = (path, reference)
if 'ref' in kwargs and kwargs['ref']:
reference = kwargs['ref']

if logmsg:
kwargs['m'] = logmsg
elif 'message' in kwargs and kwargs['message']:
Expand All @@ -107,11 +111,13 @@ def create(cls, repo: 'Repo', path: PathLike, reference: Union[Commit_ish, str]
if force:
kwargs['f'] = True

args = (path, reference)

repo.git.tag(*args, **kwargs)
return TagReference(repo, "%s/%s" % (cls._common_path_default, path))

@classmethod
def delete(cls, repo: 'Repo', *tags: 'TagReference') -> None:
def delete(cls, repo: 'Repo', *tags: 'TagReference') -> None: # type: ignore[override]
"""Delete the given existing tag or tags"""
repo.git.tag("-d", *tags)

Expand Down