summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominic <yobmod@gmail.com>2021-07-31 13:54:17 +0100
committerGitHub <noreply@github.com>2021-07-31 13:54:17 +0100
commitef32490ae3bda224000230938a6f95d5d8692c9f (patch)
treef413a9c1c975c8a1aaa1a8d4f5408ba6a77c3575
parent37fa31decc9ab74621590cb25791ccd8d3bf0583 (diff)
parenta5a05d153ecdbd9b9bdb285a77f5b14d9c0344b0 (diff)
downloadgitpython-ef32490ae3bda224000230938a6f95d5d8692c9f.tar.gz
Merge pull request #1305 from gitpython-developers/typing
Improve types of objects/
-rw-r--r--git/objects/commit.py1
-rw-r--r--git/objects/submodule/base.py8
-rw-r--r--git/objects/submodule/root.py4
3 files changed, 7 insertions, 6 deletions
diff --git a/git/objects/commit.py b/git/objects/commit.py
index 884f6522..9d709656 100644
--- a/git/objects/commit.py
+++ b/git/objects/commit.py
@@ -128,6 +128,7 @@ class Commit(base.Object, TraversableIterableObj, Diffable, Serializable):
as what time.altzone returns. The sign is inverted compared to git's
UTC timezone."""
super(Commit, self).__init__(repo, binsha)
+ self.binsha = binsha
if tree is not None:
assert isinstance(tree, Tree), "Tree needs to be a Tree instance, was %s" % type(tree)
if tree is not None:
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py
index 29212167..14351190 100644
--- a/git/objects/submodule/base.py
+++ b/git/objects/submodule/base.py
@@ -563,6 +563,7 @@ class Submodule(IndexObject, TraversableIterableObj):
progress.update(op, i, len_rmts, prefix + "Done fetching remote of submodule %r" % self.name)
# END fetch new data
except InvalidGitRepositoryError:
+ mrepo = None
if not init:
return self
# END early abort if init is not allowed
@@ -603,7 +604,7 @@ class Submodule(IndexObject, TraversableIterableObj):
# make sure HEAD is not detached
mrepo.head.set_reference(local_branch, logmsg="submodule: attaching head to %s" % local_branch)
- mrepo.head.ref.set_tracking_branch(remote_branch)
+ mrepo.head.reference.set_tracking_branch(remote_branch)
except (IndexError, InvalidGitRepositoryError):
log.warning("Failed to checkout tracking branch %s", self.branch_path)
# END handle tracking branch
@@ -629,13 +630,14 @@ class Submodule(IndexObject, TraversableIterableObj):
if mrepo is not None and to_latest_revision:
msg_base = "Cannot update to latest revision in repository at %r as " % mrepo.working_dir
if not is_detached:
- rref = mrepo.head.ref.tracking_branch()
+ rref = mrepo.head.reference.tracking_branch()
if rref is not None:
rcommit = rref.commit
binsha = rcommit.binsha
hexsha = rcommit.hexsha
else:
- log.error("%s a tracking branch was not set for local branch '%s'", msg_base, mrepo.head.ref)
+ log.error("%s a tracking branch was not set for local branch '%s'",
+ msg_base, mrepo.head.reference)
# END handle remote ref
else:
log.error("%s there was no local tracking branch", msg_base)
diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py
index bcac5419..5e84d161 100644
--- a/git/objects/submodule/root.py
+++ b/git/objects/submodule/root.py
@@ -2,9 +2,7 @@ from .base import (
Submodule,
UpdateProgress
)
-from .util import (
- find_first_remote_branch
-)
+from .util import find_first_remote_branch
from git.exc import InvalidGitRepositoryError
import git