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

Commit7328a00

Browse files
committed
Start fixing annotations that used the old Commit_ish
1 parent1fe4dc8 commit7328a00

File tree

5 files changed

+63
-60
lines changed

5 files changed

+63
-60
lines changed

‎git/objects/base.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,30 @@
33
# This module is part of GitPython and is released under the
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

6-
fromgit.excimportWorkTreeRepositoryUnsupported
7-
fromgit.utilimportLazyMixin,join_path_native,stream_copy,bin_to_hex
8-
96
importgitdb.typasdbtyp
107
importos.pathasosp
118

9+
fromgit.excimportWorkTreeRepositoryUnsupported
10+
fromgit.utilimportLazyMixin,join_path_native,stream_copy,bin_to_hex
11+
1212
from .utilimportget_object_type_by_name
1313

1414

1515
# typing ------------------------------------------------------------------
1616

1717
fromtypingimportAny,TYPE_CHECKING,Union
1818

19-
fromgit.typesimportGitObjectTypeString,Old_commit_ish,PathLike
19+
fromgit.typesimportAnyGitObject,GitObjectTypeString,PathLike
2020

2121
ifTYPE_CHECKING:
22-
fromgit.repoimportRepo
2322
fromgitdb.baseimportOStream
23+
24+
fromgit.refs.referenceimportReference
25+
fromgit.repoimportRepo
26+
2427
from .treeimportTree
2528
from .blobimportBlob
2629
from .submodule.baseimportSubmodule
27-
fromgit.refs.referenceimportReference
2830

2931
IndexObjUnion=Union["Tree","Blob","Submodule"]
3032

@@ -115,7 +117,7 @@ def __init__(self, repo: "Repo", binsha: bytes):
115117
)
116118

117119
@classmethod
118-
defnew(cls,repo:"Repo",id:Union[str,"Reference"])->Old_commit_ish:
120+
defnew(cls,repo:"Repo",id:Union[str,"Reference"])->AnyGitObject:
119121
"""
120122
:return:
121123
New :class:`Object` instance of a type appropriate to the object type behind
@@ -132,7 +134,7 @@ def new(cls, repo: "Repo", id: Union[str, "Reference"]) -> Old_commit_ish:
132134
returnrepo.rev_parse(str(id))
133135

134136
@classmethod
135-
defnew_from_sha(cls,repo:"Repo",sha1:bytes)->Old_commit_ish:
137+
defnew_from_sha(cls,repo:"Repo",sha1:bytes)->AnyGitObject:
136138
"""
137139
:return:
138140
New object instance of a type appropriate to represent the given binary sha1

‎git/refs/symbolic.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,38 @@
66
fromgit.compatimportdefenc
77
fromgit.objectsimportObject
88
fromgit.objects.commitimportCommit
9+
fromgit.refs.logimportRefLog
910
fromgit.utilimport (
11+
LockedFD,
12+
assure_directory_exists,
13+
hex_to_bin,
1014
join_path,
1115
join_path_native,
1216
to_native_path_linux,
13-
assure_directory_exists,
14-
hex_to_bin,
15-
LockedFD,
1617
)
17-
fromgitdb.excimportBadObject,BadName
18-
19-
from .logimportRefLog
18+
fromgitdb.excimportBadName,BadObject
2019

2120
# typing ------------------------------------------------------------------
2221

2322
fromtypingimport (
2423
Any,
2524
Iterator,
2625
List,
26+
TYPE_CHECKING,
2727
Tuple,
2828
Type,
2929
TypeVar,
3030
Union,
31-
TYPE_CHECKING,
3231
cast,
3332
)
34-
fromgit.typesimportOld_commit_ish,PathLike
33+
fromgit.typesimportAnyGitObject,PathLike
3534

3635
ifTYPE_CHECKING:
37-
fromgit.repoimportRepo
38-
fromgit.refsimportHead,TagReference,RemoteReference,Reference
39-
from .logimportRefLogEntry
4036
fromgit.configimportGitConfigParser
4137
fromgit.objects.commitimportActor
38+
fromgit.refsimportHead,TagReference,RemoteReference,Reference
39+
fromgit.refs.logimportRefLogEntry
40+
fromgit.repoimportRepo
4241

4342

4443
T_References=TypeVar("T_References",bound="SymbolicReference")
@@ -278,7 +277,7 @@ def _get_ref_info(cls, repo: "Repo", ref_path: Union[PathLike, None]) -> Union[T
278277
"""
279278
returncls._get_ref_info_helper(repo,ref_path)
280279

281-
def_get_object(self)->Old_commit_ish:
280+
def_get_object(self)->AnyGitObject:
282281
"""
283282
:return:
284283
The object our ref currently refers to. Refs can be cached, they will always
@@ -345,17 +344,20 @@ def set_commit(
345344

346345
defset_object(
347346
self,
348-
object:Union[Old_commit_ish,"SymbolicReference",str],
347+
object:Union[AnyGitObject,"SymbolicReference",str],
349348
logmsg:Union[str,None]=None,
350349
)->"SymbolicReference":
351350
"""Set the object we point to, possibly dereference our symbolic reference
352351
first. If the reference does not exist, it will be created.
353352
354353
:param object:
355354
A refspec, a :class:`SymbolicReference` or an
356-
:class:`~git.objects.base.Object` instance. :class:`SymbolicReference`
357-
instances will be dereferenced beforehand to obtain the object they point
358-
to.
355+
:class:`~git.objects.base.Object` instance.
356+
357+
* :class:`SymbolicReference` instances will be dereferenced beforehand to
358+
obtain the git object they point to.
359+
* :class:`~git.objects.base.Object` instances must represent git objects
360+
(:class:`~git.types.AnyGitObject`).
359361
360362
:param logmsg:
361363
If not ``None``, the message will be used in the reflog entry to be written.
@@ -404,22 +406,22 @@ def _get_reference(self) -> "SymbolicReference":
404406

405407
defset_reference(
406408
self,
407-
ref:Union[Old_commit_ish,"SymbolicReference",str],
409+
ref:Union[AnyGitObject,"SymbolicReference",str],
408410
logmsg:Union[str,None]=None,
409411
)->"SymbolicReference":
410412
"""Set ourselves to the given `ref`.
411413
412-
It will stay a symbol if the ref is a :class:`~git.refs.reference.Reference`.
414+
It will stay a symbol if the`ref` is a :class:`~git.refs.reference.Reference`.
413415
414-
Otherwisean Object, given as :class:`~git.objects.base.Object` instance or
415-
refspec, is assumed and ifvalid, will be setwhich effectively detaches the
416-
reference if it was a purely symbolic one.
416+
Otherwisea git object, specified asa:class:`~git.objects.base.Object`
417+
instance orrefspec, is assumed. If it isvalid,this referencewill be setto
418+
it, which effectively detaches thereference if it was a purely symbolic one.
417419
418420
:param ref:
419421
A :class:`SymbolicReference` instance, an :class:`~git.objects.base.Object`
420-
instance, or a refspec string. Only if the ref is a
421-
:class:`SymbolicReference` instance, we will point to it. Everything else is
422-
dereferenced to obtain the actual object.
422+
instance (specifically an :class:`~git.types.AnyGitObject`), or a refspec
423+
string. Only if the ref is a:class:`SymbolicReference` instance, we will
424+
point to it. Everything else isdereferenced to obtain the actual object.
423425
424426
:param logmsg:
425427
If set to a string, the message will be used in the reflog.

‎git/refs/tag.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414

1515
# typing ------------------------------------------------------------------
1616

17-
fromtypingimportAny,Type,Union,TYPE_CHECKING
18-
fromgit.typesimportOld_commit_ish,PathLike
17+
fromtypingimportAny,TYPE_CHECKING,Type,Union
18+
19+
fromgit.typesimportAnyGitObject,PathLike
1920

2021
ifTYPE_CHECKING:
21-
fromgit.repoimportRepo
2222
fromgit.objectsimportCommit
2323
fromgit.objectsimportTagObject
2424
fromgit.refsimportSymbolicReference
25+
fromgit.repoimportRepo
2526

2627

2728
# ------------------------------------------------------------------------------
@@ -82,7 +83,7 @@ def tag(self) -> Union["TagObject", None]:
8283

8384
# Make object read-only. It should be reasonably hard to adjust an existing tag.
8485
@property
85-
defobject(self)->Old_commit_ish:# type: ignore[override]
86+
defobject(self)->AnyGitObject:# type: ignore[override]
8687
returnReference._get_object(self)
8788

8889
@classmethod

‎git/remote.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@
4444
fromgit.typesimportPathLike,Literal,Old_commit_ish
4545

4646
ifTYPE_CHECKING:
47-
fromgit.repo.baseimportRepo
47+
fromgit.objects.commitimportCommit
4848
fromgit.objects.submodule.baseimportUpdateProgress
49-
50-
# from git.objects.commit import Commit
51-
# from git.objects import Blob, Tree, TagObject
49+
fromgit.repo.baseimportRepo
5250

5351
flagKeyLiteral=Literal[" ","!","+","-","*","=","t","?"]
5452

@@ -381,7 +379,7 @@ def name(self) -> str:
381379
returnself.ref.name
382380

383381
@property
384-
defcommit(self)->Old_commit_ish:
382+
defcommit(self)->"Commit":
385383
""":return: Commit of our remote ref"""
386384
returnself.ref.commit
387385

‎git/repo/base.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,29 @@
3434
fromgit.remoteimportRemote,add_progress,to_progress_instance
3535
fromgit.utilimport (
3636
Actor,
37-
finalize_process,
3837
cygpath,
39-
hex_to_bin,
4038
expand_path,
39+
finalize_process,
40+
hex_to_bin,
4141
remove_password_if_present,
4242
)
4343

4444
from .funimport (
45-
rev_parse,
46-
is_git_dir,
4745
find_submodule_git_dir,
48-
touch,
4946
find_worktree_git_dir,
47+
is_git_dir,
48+
rev_parse,
49+
touch,
5050
)
5151

5252
# typing ------------------------------------------------------
5353

5454
fromgit.typesimport (
55-
TBD,
56-
PathLike,
57-
Lit_config_levels,
58-
Old_commit_ish,
5955
CallableProgress,
56+
Commit_ish,
57+
Lit_config_levels,
58+
PathLike,
59+
TBD,
6060
Tree_ish,
6161
assert_never,
6262
)
@@ -68,25 +68,25 @@
6868
Iterator,
6969
List,
7070
Mapping,
71+
NamedTuple,
7172
Optional,
7273
Sequence,
74+
TYPE_CHECKING,
7375
TextIO,
7476
Tuple,
7577
Type,
7678
Union,
77-
NamedTuple,
7879
cast,
79-
TYPE_CHECKING,
8080
)
8181

8282
fromgit.typesimportConfigLevels_Tup,TypedDict
8383

8484
ifTYPE_CHECKING:
85-
fromgit.utilimportIterableList
86-
fromgit.refs.symbolicimportSymbolicReference
8785
fromgit.objectsimportTree
8886
fromgit.objects.submodule.baseimportUpdateProgress
87+
fromgit.refs.symbolicimportSymbolicReference
8988
fromgit.remoteimportRemoteProgress
89+
fromgit.utilimportIterableList
9090

9191
# -----------------------------------------------------------
9292

@@ -96,7 +96,7 @@
9696

9797

9898
classBlameEntry(NamedTuple):
99-
commit:Dict[str,"Commit"]
99+
commit:Dict[str,Commit]
100100
linenos:range
101101
orig_path:Optional[str]
102102
orig_linenos:range
@@ -696,7 +696,7 @@ def config_writer(self, config_level: Lit_config_levels = "repository") -> GitCo
696696
"""
697697
returnGitConfigParser(self._get_config_path(config_level),read_only=False,repo=self,merge_includes=False)
698698

699-
defcommit(self,rev:Union[str,Old_commit_ish,None]=None)->Commit:
699+
defcommit(self,rev:Union[str,Commit_ish,None]=None)->Commit:
700700
"""The :class:`~git.objects.commit.Commit` object for the specified revision.
701701
702702
:param rev:
@@ -772,7 +772,7 @@ def iter_commits(
772772

773773
returnCommit.iter_items(self,rev,paths,**kwargs)
774774

775-
defmerge_base(self,*rev:TBD,**kwargs:Any)->List[Union[Old_commit_ish,None]]:
775+
defmerge_base(self,*rev:TBD,**kwargs:Any)->List[Commit]:
776776
R"""Find the closest common ancestor for the given revision
777777
(:class:`~git.objects.commit.Commit`\s, :class:`~git.refs.tag.Tag`\s,
778778
:class:`~git.refs.reference.Reference`\s, etc.).
@@ -797,9 +797,9 @@ def merge_base(self, *rev: TBD, **kwargs: Any) -> List[Union[Old_commit_ish, Non
797797
raiseValueError("Please specify at least two revs, got only %i"%len(rev))
798798
# END handle input
799799

800-
res:List[Union[Old_commit_ish,None]]= []
800+
res:List[Commit]= []
801801
try:
802-
lines=self.git.merge_base(*rev,**kwargs).splitlines()# List[str]
802+
lines:List[str]=self.git.merge_base(*rev,**kwargs).splitlines()
803803
exceptGitCommandErroraserr:
804804
iferr.status==128:
805805
raise
@@ -815,7 +815,7 @@ def merge_base(self, *rev: TBD, **kwargs: Any) -> List[Union[Old_commit_ish, Non
815815

816816
returnres
817817

818-
defis_ancestor(self,ancestor_rev:"Commit",rev:"Commit")->bool:
818+
defis_ancestor(self,ancestor_rev:Commit,rev:Commit)->bool:
819819
"""Check if a commit is an ancestor of another.
820820
821821
:param ancestor_rev:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp