GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Join `Pathlike` Object to Tree by George-Ogden · Pull Request #2094 · gitpython-developers/GitPython

Conversation

@George-Ogden

@George-Ogden George-Ogden commented Dec 12, 2025

Copy link
Copy Markdown
Contributor

This extends the Tree.join and Tree.__truediv__ API to allow a pathlike object.
For example:

repo = Repo(my_local_repo)
interesting_filepath: Path = Path(folder) / file
blob = repo.tree() / interesting_filepath

This did not work before without explicitly converting the Path to a string, but works now.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
George-Ogden added 2 commits December 12, 2025 21:41
@George-Ogden
Add failing tests for joining paths
9fa28ae
@George-Ogden
Allow joining path to tree
88e2614
@Byron
Byron requested a review from Copilot December 14, 2025 13:37
Copilot started reviewing on behalf of Byron December 14, 2025 13:37
View session
@Byron

Byron commented Dec 14, 2025

Copy link
Copy Markdown
Member

Thanks a lot, this looks very good to me!

It's a bit sad that we have some test duplication to validate various types, but I guess it's better than not having them.
I will merge unless Copilot comes up with something more than nits that I can just apply.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot AI reviewed Dec 14, 2025
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the Tree.join and Tree.__truediv__ API to support pathlike objects (such as pathlib.Path), enabling more Pythonic path handling when traversing Git tree objects. Previously, users had to explicitly convert Path objects to strings; now they can use them directly with the / operator.

  • Type annotations updated from str to PathLike for both methods
  • Implementation uses os.fspath() to convert PathLike objects to strings
  • Comprehensive test coverage added for PathLike support with various scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
git/objects/tree.py Updated join() and __truediv__() methods to accept PathLike parameters; added os.fspath() conversion; imported os module
test/test_tree.py Added comprehensive test cases for string and PathLike path lookups covering simple, nested, folder, and invalid path scenarios; imported pytest, Repo, and PathLikeMock

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/test_tree.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/test_tree.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/test_tree.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Copilot AI reviewed Dec 14, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@George-Ogden
Update test/test_tree.py
c8b58c0
Rename blob to tree

Co-authored-by: Copilot <[email protected]>
@Byron
Byron merged commit b8bb60e into gitpython-developers:main Dec 15, 2025
27 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@George-Ogden @Byron
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.