@@ -72,7 +72,7 @@ def open(
72
72
path = "/" .join (key )
73
73
blob_kwargs = {
74
74
"as_path" : path ,
75
- "commit_id" : commit .oid ,
75
+ "commit_id" : commit .id ,
76
76
}
77
77
blobio = BlobIO (self .obj , ** blob_kwargs )
78
78
if mode == "rb" :
@@ -108,7 +108,7 @@ def size(self) -> int: # pylint: disable=invalid-overridden-method
108
108
109
109
@property
110
110
def sha (self ) -> str :
111
- return self .obj .hex
111
+ return str ( self .obj .id )
112
112
113
113
def scandir (self ) -> Iterable ["Pygit2Object" ]:
114
114
for entry in self .obj :
@@ -190,12 +190,13 @@ def _refdb(self):
190
190
return RefdbFsBackend (self .repo )
191
191
192
192
def _resolve_refish (self , refish : str ):
193
- from pygit2 import GIT_OBJ_COMMIT , Tag
193
+ from pygit2 import Tag
194
+ from pygit2 .enums import ObjectType
194
195
195
196
commit , ref = self .repo .resolve_refish (refish )
196
197
if isinstance (commit , Tag ):
197
198
ref = commit
198
- commit = commit .peel (GIT_OBJ_COMMIT )
199
+ commit = commit .peel (ObjectType . COMMIT )
199
200
return commit , ref
200
201
201
202
@property
@@ -395,7 +396,8 @@ def tag(
395
396
annotated : bool = False ,
396
397
message : Optional [str ] = None ,
397
398
):
398
- from pygit2 import GIT_OBJ_COMMIT , GitError
399
+ from pygit2 import GitError
400
+ from pygit2 .enums import ObjectType
399
401
400
402
if annotated and not message :
401
403
raise SCMError ("message is required for annotated tag" )
@@ -404,7 +406,7 @@ def tag(
404
406
self .repo .create_tag (
405
407
tag ,
406
408
target_obj .id ,
407
- GIT_OBJ_COMMIT ,
409
+ ObjectType . COMMIT ,
408
410
self .committer ,
409
411
message or "" ,
410
412
)
@@ -526,20 +528,21 @@ def set_ref(
526
528
self .repo .create_reference_direct (name , new_ref , True , message = message )
527
529
528
530
def get_ref (self , name , follow : bool = True ) -> Optional [str ]:
529
- from pygit2 import GIT_OBJ_COMMIT , GIT_REF_SYMBOLIC , InvalidSpecError , Tag
531
+ from pygit2 import InvalidSpecError , Tag
532
+ from pygit2 .enums import ObjectType , ReferenceType
530
533
531
534
try :
532
535
ref = self .repo .references .get (name )
533
536
except InvalidSpecError :
534
537
return None
535
538
if not ref :
536
539
return None
537
- if follow and ref .type == GIT_REF_SYMBOLIC :
540
+ if follow and ref .type == ReferenceType . SYMBOLIC :
538
541
ref = ref .resolve ()
539
542
try :
540
543
obj = self .repo [ref .target ]
541
544
if isinstance (obj , Tag ):
542
- return str (obj .peel (GIT_OBJ_COMMIT ).id )
545
+ return str (obj .peel (ObjectType . COMMIT ).id )
543
546
except ValueError :
544
547
pass
545
548
@@ -841,7 +844,7 @@ def reset(self, hard: bool = False, paths: Optional[Iterable[str]] = None):
841
844
if os .name == "nt" :
842
845
rel = rel .replace ("\\ " , "/" )
843
846
obj = tree [rel ]
844
- self .repo .index .add (IndexEntry (rel , obj .oid , obj .filemode ))
847
+ self .repo .index .add (IndexEntry (rel , obj .id , obj .filemode ))
845
848
self .repo .index .write ()
846
849
elif hard :
847
850
self .repo .reset (self .repo .head .target , GIT_RESET_HARD )
@@ -1077,7 +1080,7 @@ def get_tag(self, name: str) -> Optional[Union[str, "GitTag"]]:
1077
1080
if isinstance (tag , Tag ):
1078
1081
return GitTag (
1079
1082
tag .name ,
1080
- str (tag .oid ),
1083
+ str (tag .id ),
1081
1084
str (tag .target ),
1082
1085
tag .tagger .name ,
1083
1086
tag .tagger .email ,
0 commit comments