#5492 pygit2 1.15.0 (2024-05-18) - breaking changes affect pagure
Opened 10 months ago by wombelix. Modified 3 months ago

We didn't pin the pygit2 version and the current release contains a lot breaking changes that affect pagure.
Currently unit tests failing, everything related deprecated features that were now removed, e.g. :

FAILED tests/test_pagure_merge_pr_no_fork.py::PagureMergePrNoForkTest::test_api_pull_request_diffstats_no_fork - AttributeError: '_pygit2.Oid' object has no attribute 'hex'
FAILED tests/test_pagure_merge_pr_no_fork.py::PagureMergePrNoForkTest::test_api_pull_request_merge_no_fork - AttributeError: '_pygit2.Oid' object has no attribute 'hex'
FAILED tests/test_pagure_merge_pr_no_fork.py::PagureMergePrNoForkTest::test_internal_merge_status - AttributeError: '_pygit2.Oid' object has no attribute 'hex'
FAILED tests/test_pagure_merge_pr_no_fork.py::PagureMergePrNoForkTest::test_ui_pull_request_merge_no_fork - AttributeError: '_pygit2.Oid' object has no attribute 'hex'
FAILED tests/test_pagure_merge_pr_no_fork.py::PagureMergePrNoForkTest::test_ui_pull_request_merge - AttributeError: '_pygit2.Oid' object has no attribute 'hex'
FAILED tests/test_pagure_merge_pr_no_fork.py::PagureMergePrNoForkTest::test_internal_merge_status_no_fork - AttributeError: '_pygit2.Oid' object has no attribute 'hex'
FAILED tests/test_pagure_send_notification.py::PagureHooksDefault::test_send_notifications - AttributeError: '_pygit2.Oid' object has no attribute 'hex'
FAILED tests/test_pagure_send_notification.py::PagureHooksDefault::test_send_action_notification - AttributeError: '_pygit2.Oid' object has no attribute 'hex'
FAILED tests/test_pagure_utils.py::PagureUtilsTests::test_lookup_deploykey_different_project - AttributeError: '_pygit2.Oid' object has no attribute 'hex'
FAILED tests/test_pagure_merge_pr_no_fork.py::PagureMergePrNoForkTest::test_api_pull_request_merge - AttributeError: '_pygit2.Oid' object has no attribute 'hex'
FAILED tests/test_pagure_utils.py::PagureUtilsTests::test_lookup_deploykey_non_existent_key - AttributeError: '_pygit2.Oid' object has no attribute 'hex'
FAILED tests/test_pagure_merge_pr_no_fork.py::PagureMergePrNoForkTest::test_api_pull_request_diffstats - AttributeError: '_pygit2.Oid' object has no attribute 'hex'
FAILED tests/test_pagure_utils.py::PagureUtilsTests::test_lookup_deploykey_non_deploykey - AttributeError: '_pygit2.Oid' object has no attribute 'hex'
FAILED tests/test_style.py::TestStyle::test_code_with_flake8 - AssertionError: 1 != 0
FAILED tests/test_pagure_utils.py::PagureUtilsTests::test_lookup_deploykey - AttributeError: '_pygit2.Oid' object has no attribute 'hex'
======================================================= 508 failed, 1158 passed, 3 skipped, 6140 warnings in 1081.69s (0:18:01) =======================================================

https://github.com/libgit2/pygit2/blob/master/CHANGELOG.md

1.15.0 (2024-05-18)

  • Many deprecated features have been removed, see below

  • Upgrade to libgit2 v1.8.1

  • New push_options optional argument in Repository.push(...)
    #1282

  • New support comparison of Oid with text string

  • Fix CheckoutNotify.IGNORED
    #1288

  • Use default error handler when decoding/encoding paths
    #537

  • Remove setuptools runtime dependency
    #1281

  • Coding style with ruff
    #1280

  • Add wheels for ppc64le
    #1279

  • Fix tests on EPEL8 builds for s390x
    #1283

Deprecations:

  • Deprecate IndexEntry.hex, use str(IndexEntry.id)

Breaking changes:

  • Remove deprecated oid.hex, use str(oid)
  • Remove deprecated object.hex, use str(object.id)
  • Remove deprecated object.oid, use object.id

  • Remove deprecated Repository.add_submodule(...), use Repository.submodules.add(...)

  • Remove deprecated Repository.lookup_submodule(...), use Repository.submodules[...]
  • Remove deprecated Repository.init_submodules(...), use Repository.submodules.init(...)
  • Remove deprecated Repository.update_submodule(...), use Repository.submodules.update(...)

  • Remove deprecated constants GIT_OBJ_XXX, use ObjectType

  • Remove deprecated constants GIT_REVPARSE_XXX, use RevSpecFlag
  • Remove deprecated constants GIT_REF_XXX, use ReferenceType
  • Remove deprecated ReferenceType.OID, use instead ReferenceType.DIRECT
  • Remove deprecated ReferenceType.LISTALL, use instead ReferenceType.ALL

  • Remove deprecated support for passing dicts to repository\'s merge(...),
    merge_commits(...) and merge_trees(...). Instead pass MergeFlag for flags, and
    MergeFileFlag for file_flags.

  • Remove deprecated support for passing a string for the favor argument to repository\'s
    merge(...), merge_commits(...) and merge_trees(...). Instead pass MergeFavor.

I invested a couple of hours with the attempt to clean our tech debts and make everything pygit 1.15.0 compatible. It's a massive amount of work and I had to give up for now. PR https://pagure.io/pagure/pull-request/5493 will pin the version to <1.15.0 for pip.

For now it's also not a problem in Fedora:
- F39, F40, F41: python-pygit2-1.14.0
- EPEL 8, 9: python-pygit2-0.26.4

I did a validation what we actually use from the deprecated list.
Most of it was deprecated in versions earlier than the one there are in EPEL.
So overall it's pretty safe to just move to the recommended successors.

What I struggled with: It's very hard to identify what type the variable currently is (str or pygit obj) and if str(object.id), object.id or str(oid) has to be used. It becomes even more confusing with things like repo_obj.head.peel().oid.hex or repo_obj.revparse_single(first_commit.parents[0].oid.hex). The pygit2 documentation is pretty thin on that too.

Long story short, that is a backlog topic and something for July/August, too busy in June to further work on it.

* 0.20.2 (2014-02-04), Remove deprecated oid.hex, use str(oid)

* 0.20.2 (2014-02-04), Remove deprecated object.hex, use str(object.id)

* 0.20.2 (2014-02-04), Remove deprecated object.oid, use object.id

! 1.14.0 (2024-01-26), Remove deprecated Repository.add_submodule(...), use Repository.submodules.add(...)
- not in use

! 1.14.0 (2024-01-26), Remove deprecated Repository.lookup_submodule(...), use Repository.submodules[...]
- not in use

! 1.14.0 (2024-01-26), Remove deprecated Repository.init_submodules(...), use Repository.submodules.init(...)
- not in use

! 1.14.0 (2024-01-26), Remove deprecated Repository.update_submodule(...), use Repository.submodules.update(...)
- not in use

! 1.14.0 (2024-01-26), Remove deprecated constants GIT_OBJ_XXX, use ObjectType
- in use by a couple of tests

! 1.14.0 (2024-01-26), Remove deprecated constants GIT_REVPARSE_XXX, use RevSpecFlag
- not in use

! 1.14.0 (2024-01-26), Remove deprecated constants GIT_REF_XXX, use ReferenceType
- not in use

! 1.14.1 (2024-02-10), Remove deprecated ReferenceType.OID, use instead ReferenceType.DIRECT
- not in use

! 1.14.1 (2024-02-10), Remove deprecated ReferenceType.LISTALL, use instead ReferenceType.ALL
- not in use

! 1.14.0 (2024-01-26), Remove deprecated support for passing dicts to repository's merge(...), merge_commits(...) and merge_trees(...). Instead pass MergeFlag for flags, and MergeFileFlag for file_flags.
- unknown

! 1.14.0 (2024-01-26), Remove deprecated support for passing a string for the favor argument to repository's merge(...), merge_commits(...) and merge_trees(...). Instead pass MergeFavor.
- unknown

Metadata Update from @wombelix:
- Assignee reset

10 months ago

Commit 0c13cf0 relates to this ticket

Metadata Update from @wombelix:
- Issue assigned to wombelix

7 months ago

Edit: looks like I have a fix for this (dump/reload and plugin install are still broken, but those might be unrelated problems, the tests have never fully passed in Debian); I'll apply it to master and open a real pull request.

(Background: I am a Debian Maintainer currently in the process of taking over Debian's pagure package. This package is currently broken, because Debian unstable has pygit2 1.16. While I am aware that pagure is old and Fedora is in the process of moving its infrastructure off it, I think it is the only git forge we have in main - gitlab is in contrib (despite being what Debian's own git infrastructure runs) and forgejo is still in the process of being packaged (adding new packages to Debian is often a long process).)

Patches so far (20, 22 and 33 are the relevant ones; security warning, do NOT pull from random salsa.debian.org repositories without looking, Debian's security boundary is between git main and package upload, not the more usual between git pull request and git main)
https://salsa.debian.org/rnpalmer-guest/pagure/-/tree/ad365c564e78e218cb0887169511ede25e5dc8e5/debian/patches
CI logs
https://salsa.debian.org/rnpalmer-guest/pagure/-/jobs/6910095/raw
https://salsa.debian.org/rnpalmer-guest/pagure/-/jobs/6910096/raw

I have now filed a real pull request for this.

(Against master; Debian itself has a bigger patch stack because it's still on 5.14.x.)

I have now filed a real pull request for this.

(Against master; Debian itself has a bigger patch stack because it's still on 5.14.x.)

Fedora 41 also have pagure-5.14.1 so could be interesting also add the patches to 5.14.x branch
https://pagure.io/pagure/commits/5.14.x

Thank you

@sergiomb I've now tried to sort my 5.14 patches into what is generally
useful and what is Debian-specific; they still fail a few tests, but
they fail far fewer than stock 5.14.

(It's a big enough patch stack that I'm considering the option of
instead packaging git HEAD.)

https://salsa.debian.org/debian/pagure/-/blob/master/debian/patches/series?ref_type=heads

Log in to comment on this ticket.

Metadata
Related Pull Requests
  • #5514 Last updated 3 months ago
  • #5493 Merged 10 months ago