Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1541c62

Browse files
committed
Start on fixing Submodule parent_commit annotations
These used the old Commit_ish. They may not all be the same as eachother, since they perform different validation and some will lookup a commit while others do not. In particular, this is complicatedby how Submodile.__init__ documents its parent_commit parameter: itsays to see the set_parent_commit method. But __init__ sets the_parent_commit attribute to parent_commit, while set_parent_committreats its commit parameter differently, calling self.repo.commiton it to get get a Commit object from it even if it wasn't one tobegin with. See#1869 for full details.There may be some other subtleties as well. A number of uses of theof the old Commit_ish type appear in git.submodule.base, allrelated to parent_commit. These are all remaining references to it(identifiable due to the rename to Old_commit_ish done in04a2753),though. So once the changes begun here for git.submodule.* aredone, that will also have completed the broader replacement effortbegun in7328a00. At that point cleanup can be done in git.types(removing Old_commit_ish introduced in04a2753, replacingLit_old_commit_ish with a possibly-updated and deprecatedLit_commit_ish to avoid a breaking change, and possibly makingfurther refinements to additions to the newly added docstrings).
1 parent5b2869f commit1541c62

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

‎git/objects/submodule/base.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@
4545
fromtypingimportCallable,Dict,Mapping,Sequence,TYPE_CHECKING,cast
4646
fromtypingimportAny,Iterator,Union
4747

48-
fromgit.typesimportOld_commit_ish,Literal,PathLike,TBD
48+
fromgit.typesimportCommit_ish,Literal,Old_commit_ish,PathLike,TBD
4949

5050
ifTYPE_CHECKING:
5151
fromgit.indeximportIndexFile
52-
fromgit.repoimportRepo
52+
fromgit.objects.commitimportCommit
5353
fromgit.refsimportHead
54+
fromgit.repoimportRepo
5455

5556
# -----------------------------------------------------------------------------
5657

@@ -99,7 +100,7 @@ class Submodule(IndexObject, TraversableIterableObj):
99100
"""Submodule flags. Submodules are directories with link-status."""
100101

101102
type:Literal["submodule"]="submodule"# type: ignore
102-
"""This is a bogus type for base class compatibility."""
103+
"""This is a bogus typestringfor base class compatibility."""
103104

104105
__slots__= ("_parent_commit","_url","_branch_path","_name","__weakref__")
105106

@@ -1242,7 +1243,7 @@ def remove(
12421243

12431244
returnself
12441245

1245-
defset_parent_commit(self,commit:Union[Old_commit_ish,None],check:bool=True)->"Submodule":
1246+
defset_parent_commit(self,commit:Union[Commit_ish,str,None],check:bool=True)->"Submodule":
12461247
"""Set this instance to use the given commit whose tree is supposed to
12471248
contain the ``.gitmodules`` blob.
12481249
@@ -1495,7 +1496,7 @@ def url(self) -> str:
14951496
returnself._url
14961497

14971498
@property
1498-
defparent_commit(self)->"Old_commit_ish":
1499+
defparent_commit(self)->"Commit":
14991500
"""
15001501
:return:
15011502
:class:`~git.objects.commit.Commit` instance with the tree containing the
@@ -1557,8 +1558,8 @@ def children(self) -> IterableList["Submodule"]:
15571558
defiter_items(
15581559
cls,
15591560
repo:"Repo",
1560-
parent_commit:Union[Old_commit_ish,str]="HEAD",
1561-
*Args:Any,
1561+
parent_commit:Union[Commit_ish,str]="HEAD",
1562+
*args:Any,
15621563
**kwargs:Any,
15631564
)->Iterator["Submodule"]:
15641565
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp