I'm proposing this patch for ubuntu:
Description: Replace deprecated GIT_OBJ_XXX references Author: Andreas Hasenack <andreas.hasen...@canonical.com> Origin: vendor Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1084258 Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/git-ubuntu/+bug/2091778 Last-Update: 2024-12-14
--- a/gitubuntu/git_repository.py +++ b/gitubuntu/git_repository.py @@ -34,6 +34,7 @@ import debian.changelog import debian.debian_support import pygit2 +from pygit2.enums import ObjectType import pytest @@ -65,7 +66,7 @@ tail = None entry = _rel_tree[head] - if entry.type in [pygit2.GIT_OBJ_TREE, 'tree']: + if entry.type in [ObjectType.TREE, 'tree']: return _follow_symlinks_to_blob( repo=repo, top_tree_object=top_tree_object, @@ -73,7 +74,7 @@ _rel_tree=repo.get(entry.id), _rel_path=posixpath.join(_rel_path, head), ) - elif entry.type in [pygit2.GIT_OBJ_BLOB, 'blob'] and entry.filemode == pygit2.GIT_FILEMODE_LINK: + elif entry.type in [ObjectType.BLOB, 'blob'] and entry.filemode == pygit2.GIT_FILEMODE_LINK: # Found a symlink. Start again from the top with adjustment for symlink # following target_tail = [decode_binary(repo.get(entry.id).data)] @@ -87,7 +88,7 @@ top_tree_object=top_tree_object, search_path=search_path, ) - elif entry.type in [pygit2.GIT_OBJ_BLOB, 'blob'] and entry.filemode in NORMAL_BLOB_MODES: + elif entry.type in [ObjectType.BLOB, 'blob'] and entry.filemode in NORMAL_BLOB_MODES: return repo.get(entry.id) else: # Found some special entry such as a "gitlink" (submodule entry) @@ -2111,7 +2112,7 @@ self.raw_repo.create_tag( tag_name, pygit2.Oid(hex=commit_hash), - pygit2.GIT_OBJ_COMMIT, + ObjectType.COMMIT, tagger, tag_msg, ) @@ -2328,7 +2329,7 @@ empty TreeBuilder instead. ''' - tree = treeish.peel(pygit2.GIT_OBJ_TREE) + tree = treeish.peel(ObjectType.TREE) # Short path: sub_path == '' means want root if not sub_path: @@ -2342,7 +2343,7 @@ else: # The tree entry must itself be a tree assert tree_entry.filemode == pygit2.GIT_FILEMODE_TREE - sub_tree = repo.get(tree_entry.id).peel(pygit2.GIT_OBJ_TREE) + sub_tree = repo.get(tree_entry.id).peel(ObjectType.TREE) tree_builder = repo.TreeBuilder(sub_tree) return tree_builder --- a/gitubuntu/repo_builder.py +++ b/gitubuntu/repo_builder.py @@ -2,6 +2,7 @@ import copy import pygit2 +from pygit2.enums import ObjectType import gitubuntu.importer from gitubuntu.source_builder import Source, SourceSpec @@ -386,7 +387,7 @@ repo.create_tag( name, target.write(repo), - pygit2.GIT_OBJ_COMMIT, + ObjectType.COMMIT, self.tagger.signature, 'Tag message', ) --- a/gitubuntu/source_builder_test.py +++ b/gitubuntu/source_builder_test.py @@ -3,6 +3,7 @@ import tempfile import pygit2 +from pygit2.enums import ObjectType import pytest import gitubuntu.source_builder as target @@ -141,7 +142,7 @@ with target.Source(target.SourceSpec()) as dsc_path: top = dsc_path_to_tree(repo, dsc_path) debian_entry = top['debian'] - assert debian_entry.type in [pygit2.GIT_OBJ_TREE, 'tree'] + assert debian_entry.type in [ObjectType.TREE, 'tree'] debian = repo.raw_repo.get(debian_entry.id) with pytest.raises(KeyError): debian['patches']