Skip to content

Improve pure Python rev-parse coverage and behavior - #2136

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

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

Conversation

CopilotAI commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

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
Byronforce-pushed the copilot/create-reproducing-test-fix branch from 5372b44 to d7ce6fcCompareApril 28, 2026 22:43
@Byron
Byron marked this pull request as ready for review April 28, 2026 22:45
CopilotAI review requested due to automatic review settings April 28, 2026 22:45
@ByronByron changed the title Fix Repo.commit for tags starting with @Improve pure Python rev-parse coverage and behavior Apr 28, 2026

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

FileDescription
git/repo/fun.pyRefactors rev_parse() tokenization and adds helpers for reflog/message-search/describe parsing to prevent @-prefixed tags from failing.
test/test_repo.pyAdds a regression test covering Repo.commit() with a tag name starting with @.
test/test_rev_parse.pyIntroduces 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 threadgit/repo/fun.py Outdated
Comment threadgit/repo/fun.py
Comment threadgit/repo/fun.py Outdated
Comment threadtest/test_rev_parse.py Outdated
Comment threadtest/test_rev_parse.py
Comment threadgit/repo/fun.py Outdated
CopilotAI review requested due to automatic review settings April 28, 2026 23:11

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

FileDescription
test/test_rev_parse.pyNew focused rev-parse test suite and fixture repo construction.
test/test_repo.pyAdds regression coverage for @foo tags and stabilizes a reflog assertion.
git/repo/fun.pyRefactors/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 threadgit/repo/fun.py
Comment threadtest/test_rev_parse.py Outdated
@Byron
Byronforce-pushed the copilot/create-reproducing-test-fix branch from 96942dd to 6cf7ac3CompareApril 28, 2026 23:31
@Byron
Byron merged commit 1c4ea96 into mainApr 29, 2026
59 checks passed
Sign up for freeto 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

@Byron@codex