summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYobmod <yobmod@gmail.com>2021-07-31 17:06:22 +0100
committerYobmod <yobmod@gmail.com>2021-07-31 17:06:22 +0100
commit581d40d957fd3d7ee85c28c4dde4d6f28e104433 (patch)
tree3ac99eb7e1d4c38aa766e2a6fd78ce89720c0211
parentafd2ec5251479f48044408c7fcb7dab0494cd4c1 (diff)
downloadgitpython-581d40d957fd3d7ee85c28c4dde4d6f28e104433.tar.gz
Add type to symbolicreference.log_append()
-rw-r--r--git/refs/symbolic.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py
index 89999eda..5d3a6a0d 100644
--- a/git/refs/symbolic.py
+++ b/git/refs/symbolic.py
@@ -27,6 +27,10 @@ from git.types import Commit_ish, PathLike, TBD, Literal
if TYPE_CHECKING:
from git.repo import Repo
from git.refs import Head, TagReference, Reference
+ from .log import RefLogEntry
+ from git.config import GitConfigParser
+ from git.objects.commit import Actor
+
T_References = TypeVar('T_References', bound='SymbolicReference')
@@ -391,7 +395,8 @@ class SymbolicReference(object):
instead of calling this method repeatedly. It should be considered read-only."""
return RefLog.from_file(RefLog.path(self))
- def log_append(self, oldbinsha, message, newbinsha=None):
+ def log_append(self, oldbinsha: bytes, message: Union[str, None],
+ newbinsha: Union[bytes, None] = None) -> 'RefLogEntry':
"""Append a logentry to the logfile of this ref
:param oldbinsha: binary sha this ref used to point to
@@ -403,15 +408,19 @@ class SymbolicReference(object):
# correct to allow overriding the committer on a per-commit level.
# See https://github.com/gitpython-developers/GitPython/pull/146
try:
- committer_or_reader = self.commit.committer
+ committer_or_reader: Union['Actor', 'GitConfigParser'] = self.commit.committer
except ValueError:
committer_or_reader = self.repo.config_reader()
# end handle newly cloned repositories
- return RefLog.append_entry(committer_or_reader, RefLog.path(self), oldbinsha,
- (newbinsha is None and self.commit.binsha) or newbinsha,
- message)
+ if newbinsha is None:
+ newbinsha = self.commit.binsha
+
+ if message is None:
+ message = ''
+
+ return RefLog.append_entry(committer_or_reader, RefLog.path(self), oldbinsha, newbinsha, message)
- def log_entry(self, index):
+ def log_entry(self, index: int) -> 'RefLogEntry':
""":return: RefLogEntry at the given index
:param index: python list compatible positive or negative index