Skip to content

Add test for Git LFS repository cloning#10724

Open
jelmer wants to merge 1 commit intopython-poetry:mainfrom
jelmer:lfs
Open

Add test for Git LFS repository cloning#10724
jelmer wants to merge 1 commit intopython-poetry:mainfrom
jelmer:lfs

Conversation

@jelmer
Copy link
Contributor

@jelmer jelmer commented Feb 9, 2026

Verifies that Poetry can successfully clone Git repositories that use Git Large File Storage (LFS) and that LFS files are properly retrieved with their actual content rather than just pointer files.

Resolves: #8723

  • Added tests for changed code.
  • Updated documentation for changed code.

Summary by Sourcery

Tests:

  • Add an integration-style test that initializes a Git repo with Git LFS configuration and verifies Poetry can clone it with LFS files materialized to their real content.

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 9, 2026

Reviewer's Guide

Adds an integration-style test ensuring Git LFS repositories are cloned correctly by the Git backend, verifying that LFS-tracked files are materialized with their actual binary content rather than remaining as pointer files.

File-Level Changes

Change Details Files
Add a new Git backend test that sets up a local repository with Git LFS, commits both regular and LFS-tracked files, clones it via the Git backend, and asserts that cloned files (including the LFS file) contain the expected content.
  • Introduce test_clone_with_lfs_files marked with skip_git_mock to run against a real dulwich-backed repository
  • Programmatically initialize a source repository with LFS support using dulwich Repo and LFSStore, including .gitattributes configuration
  • Create and commit a regular text file and an LFS-tracked binary file whose content is stored in the LFS store while the working tree contains a pointer file
  • Clone the repository using Git.clone into a separate directory and assert .git and working tree layout are correct
  • Validate that regular.txt and .gitattributes are correctly cloned and that large.bin in the clone has the resolved binary content matching the original lfs_content
tests/vcs/git/test_backend.py

Assessment against linked issues

Issue Objective Addressed Explanation
#8723 Ensure Poetry supports installing dependencies from Git repositories that use Git LFS, such that LFS-tracked files are cloned with their actual content rather than just pointer files.

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 - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `tests/vcs/git/test_backend.py:321-323` </location>
<code_context>
+    regular_file.write_text("This is a regular file")
+    porcelain.add(repo, str(regular_file))
+
+    # Create an LFS file with a pointer
+    lfs_content = b"This is a large binary file content for LFS storage"
+    lfs_file = source_path / "large.bin"
+
+    # Store the actual content in LFS store and create pointer
</code_context>

<issue_to_address>
**suggestion (testing):** Add an assertion that the source working tree actually contains the LFS pointer before cloning

Please also assert that `large.bin` in the source repo contains the LFS pointer text (not the raw content) before cloning. This makes the test explicitly verify that the clone + LFS integration is what materializes the real content, rather than assuming the initial file state.
</issue_to_address>

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.

Comment on lines +321 to +328
# Create an LFS file with a pointer
lfs_content = b"This is a large binary file content for LFS storage"
lfs_file = source_path / "large.bin"
Copy link

Choose a reason for hiding this comment

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

suggestion (testing): Add an assertion that the source working tree actually contains the LFS pointer before cloning

Please also assert that large.bin in the source repo contains the LFS pointer text (not the raw content) before cloning. This makes the test explicitly verify that the clone + LFS integration is what materializes the real content, rather than assuming the initial file state.

Verifies that Poetry can successfully clone Git repositories that use
Git Large File Storage (LFS) and that LFS files are properly retrieved
with their actual content rather than just pointer files.

Fixes python-poetry#8723
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.

Support for Git Repository Packages which have LFS

1 participant