Skip to content

Improve pure Python rev-parse coverage and behavior #2136

Merged
Byron merged 3 commits intomainfrom
copilot/create-reproducing-test-fix
Apr 29, 2026
Merged

Improve pure Python rev-parse coverage and behavior #2136
Byron merged 3 commits intomainfrom
copilot/create-reproducing-test-fix

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

Port object-resolving revspec cases inspired by gix-revision into deterministic GitPython tests, without shelling out to Git or Gix at runtime. Refactor rev_parse handling around anchors, navigation, peeling, reflog selectors, path/index lookups, describe-style names, and commit-message searches.

Document observed Git/Gix behavior differences and the GitPython choices made for user-facing compatibility.

Port object-resolving revspec cases inspired by gix-revision into deterministic GitPython tests, without shelling out to Git or Gix at runtime. Refactor rev_parse handling around anchors, navigation, peeling, reflog selectors, path/index lookups, describe-style names, and commit-message searches.

Document observed Git/Gix behavior differences and the GitPython choices made for user-facing compatibility.

Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
@Byron Byron force-pushed the copilot/create-reproducing-test-fix branch from 5372b44 to d7ce6fc Compare April 28, 2026 22:43
@Byron Byron marked this pull request as ready for review April 28, 2026 22:45
Copilot AI review requested due to automatic review settings April 28, 2026 22:45
@Byron Byron changed the title Fix Repo.commit for tags starting with @ Improve pure Python rev-parse coverage and behavior Apr 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 addresses issue #2135 by updating GitPython’s revision parsing so Repo.commit()/rev_parse() can resolve tag names that start with @ (e.g., @foo) without misinterpreting them as reflog syntax.

Changes:

  • Add regression tests for repo.commit("@foo") and for rev_parse() handling of names beginning with @.
  • Refactor and extend rev_parse() parsing logic to better distinguish tokens vs. literal @ in ref names, and to support additional rev-parse forms.
  • Add helper functions for reflog parsing, message search, and describe-style name resolution.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
git/repo/fun.py Refactors rev_parse() tokenization and adds helpers for reflog/message-search/describe parsing to prevent @-prefixed tags from failing.
test/test_repo.py Adds a regression test covering Repo.commit() with a tag name starting with @.
test/test_rev_parse.py Introduces a new pytest module covering rev_parse() behavior for @ names, navigation/peeling, reflog selectors, and invalid specs.

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

Comment thread git/repo/fun.py Outdated
Comment thread git/repo/fun.py
Comment thread git/repo/fun.py Outdated
Comment thread test/test_rev_parse.py Outdated
Comment thread test/test_rev_parse.py
Comment thread git/repo/fun.py Outdated
Copilot AI review requested due to automatic review settings April 28, 2026 23:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds expanded revision-spec parsing behavior and a dedicated test suite to increase deterministic coverage of Repo.rev_parse edge cases (describe-style names, navigation/peeling, reflog selectors, index/tree path lookups, and commit-message searches).

Changes:

  • Introduce a new test/test_rev_parse.py with targeted revspec cases and a purpose-built repo fixture.
  • Extend git/repo/fun.py::rev_parse and helpers to support additional revspec forms (describe-style names, reflog selectors, path/index lookups, and message searches).
  • Add/adjust tests in test/test_repo.py for tags starting with @ and make reflog-history assertions more robust.

Reviewed changes

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

File Description
test/test_rev_parse.py New focused rev-parse test suite and fixture repo construction.
test/test_repo.py Adds regression coverage for @foo tags and stabilizes a reflog assertion.
git/repo/fun.py Refactors/enhances rev_parse with new parsing helpers and added revspec support.

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

Comment thread git/repo/fun.py
Comment thread test/test_rev_parse.py Outdated
@Byron Byron force-pushed the copilot/create-reproducing-test-fix branch from 96942dd to 6cf7ac3 Compare April 28, 2026 23:31
@Byron Byron merged commit 1c4ea96 into main Apr 29, 2026
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

repo.commit doesn't work for tag starting with @

4 participants