diff options
author | Dominic <yobmod@gmail.com> | 2021-07-31 13:15:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-31 13:15:02 +0100 |
commit | e2d5e0e42a7bb664560133d1c3efeb7b4686f7c7 (patch) | |
tree | 7f051e05943951df2489c6333bc2a23f99fbe92f | |
parent | b833eebece8d0c6cb1c79bc06e8ff9f26b994bb6 (diff) | |
download | gitpython-e2d5e0e42a7bb664560133d1c3efeb7b4686f7c7.tar.gz |
Update head.py
-rw-r--r-- | git/refs/head.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/git/refs/head.py b/git/refs/head.py index 338efce9..260bf5e7 100644 --- a/git/refs/head.py +++ b/git/refs/head.py @@ -1,4 +1,4 @@ -from git.config import SectionConstraint +from git.config import GitConfigParser, SectionConstraint from git.util import join_path from git.exc import GitCommandError @@ -142,7 +142,7 @@ class Head(Reference): flag = "-D" repo.git.branch(flag, *heads) - def set_tracking_branch(self, remote_reference: 'RemoteReference') -> 'Head': + def set_tracking_branch(self, remote_reference: Union['RemoteReference', None]) -> 'Head': """ Configure this branch to track the given remote reference. This will alter this branch's configuration accordingly. @@ -203,7 +203,7 @@ class Head(Reference): self.path = "%s/%s" % (self._common_path_default, new_path) return self - def checkout(self, force: bool = False, **kwargs: Any): + def checkout(self, force: bool = False, **kwargs: Any) -> Union['HEAD', 'Head']: """Checkout this head by setting the HEAD to this reference, by updating the index to reflect the tree we point to and by updating the working tree to reflect the latest index. @@ -235,10 +235,11 @@ class Head(Reference): self.repo.git.checkout(self, **kwargs) if self.repo.head.is_detached: return self.repo.head - return self.repo.active_branch + else: + return self.repo.active_branch #{ Configuration - def _config_parser(self, read_only: bool) -> SectionConstraint: + def _config_parser(self, read_only: bool) -> SectionConstraint[GitConfigParser]: if read_only: parser = self.repo.config_reader() else: @@ -247,13 +248,13 @@ class Head(Reference): return SectionConstraint(parser, 'branch "%s"' % self.name) - def config_reader(self) -> SectionConstraint: + def config_reader(self) -> SectionConstraint[GitConfigParser]: """ :return: A configuration parser instance constrained to only read this instance's values""" return self._config_parser(read_only=True) - def config_writer(self) -> SectionConstraint: + def config_writer(self) -> SectionConstraint[GitConfigParser]: """ :return: A configuration writer instance with read-and write access to options of this head""" |