Skip to content

Bump dulwich to 0.24.0 and update deprecated API usage #10492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jelmer
Copy link
Contributor

@jelmer jelmer commented Aug 4, 2025

  • Update dulwich version constraint from >=0.22.6,<0.23.0 to >=0.24.0,<0.25.0
  • Use the new WorkTree API in Dulwich, fixing deprecation warnings

Summary by Sourcery

Bump Dulwich dependency and migrate to its new WorkTree API to resolve deprecation warnings

Enhancements:

  • replace deprecated Repo.stage and Repo.do_commit calls with WorkTree.stage and WorkTree.commit in the Git backend

Build:

  • update dulwich version constraint to >=0.24.0,<0.25.0

Tests:

  • update temp_repo fixtures to use WorkTree.stage and WorkTree.commit in tests/vcs/git/conftest.py

Copy link

sourcery-ai bot commented Aug 4, 2025

Reviewer's Guide

This PR upgrades the dulwich dependency to the 0.24.x series and replaces all deprecated direct repository operations with the new WorkTree API, ensuring staging, committing, and index resets use repo.get_worktree().

Class diagram for updated Dulwich WorkTree API usage

classDiagram
    class Repo {
        +get_worktree() WorkTree
    }
    class WorkTree {
        +reset_index()
    }
    Repo "1" --o "1" WorkTree : get_worktree()
Loading

File-Level Changes

Change Details Files
Bump dulwich dependency to 0.24.x
  • Update version constraint to >=0.24.0,<0.25.0
pyproject.toml
Migrate staging and commit in tests to the new WorkTree API
  • Initialize worktree via repo.get_worktree()
  • Replace repo.stage with worktree.stage
  • Replace repo.do_commit with worktree.commit
tests/vcs/git/conftest.py
Use WorkTree API for index reset in git backend
  • Replace local.reset_index() with local.get_worktree().reset_index()
src/poetry/vcs/git/backend.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @jelmer - I've reviewed your changes - here's some feedback:

  • Consider extracting get_worktree() into a small helper so you can avoid repeating local.get_worktree() and improve readability.
  • Audit the codebase for other dulwich API calls (e.g. repo.stage or repo.do_commit) to ensure all deprecated methods have been updated for v0.24.0.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting get_worktree() into a small helper so you can avoid repeating local.get_worktree() and improve readability.
- Audit the codebase for other dulwich API calls (e.g. repo.stage or repo.do_commit) to ensure all deprecated methods have been updated for v0.24.0.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

- Update dulwich version constraint from >=0.22.6,<0.23.0 to >=0.24.0,<0.25.0
- Use the new WorkTree API in Dulwich, fixing deprecation warnings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant