Skip to content

fix(remote): resolve HEAD to current branch for remote metadata#1535

Closed
leno23 wants to merge 1 commit into
orhun:mainfrom
leno23:fix-github-ref-head-1274
Closed

fix(remote): resolve HEAD to current branch for remote metadata#1535
leno23 wants to merge 1 commit into
orhun:mainfrom
leno23:fix-github-ref-head-1274

Conversation

@leno23

@leno23 leno23 commented May 25, 2026

Copy link
Copy Markdown

Summary

  • When the commit range ends with HEAD (e.g. v1.0.0..HEAD from --unreleased), remote integrations now resolve HEAD to the current local branch name before calling GitHub/GitLab/etc. APIs
  • Previously HEAD was mapped to None, which made APIs fall back to the repository default branch and miss PR metadata for commits on feature branches
  • Uses git2 via Repository::head_ref_name() instead of spawning git rev-parse

Fixes #1274

Supersedes the approach in draft PR #1275 with a git2-based implementation aligned with existing repository handling.

Test plan

  • cargo test -p git-cliff-core repo::test::head_ref_name_returns_current_branch

When the commit range ends with HEAD (e.g. from --unreleased), remote
integrations previously passed None as the ref, causing GitHub/GitLab APIs
to query the default branch instead of the current branch.

Resolve HEAD to the local branch name (or commit SHA when detached) via
git2 before fetching remote metadata.

Fixes #1274

Co-authored-by: Cursor <cursoragent@cursor.com>
@leno23 leno23 requested a review from orhun as a code owner May 25, 2026 05:57
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.63636% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.66%. Comparing base (7e35ff5) to head (58801a4).

Files with missing lines Patch % Lines
git-cliff-core/src/changelog.rs 58.83% 7 Missing ⚠️
git-cliff-core/src/repo.rs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1535      +/-   ##
==========================================
+ Coverage   48.63%   48.66%   +0.03%     
==========================================
  Files          26       26              
  Lines        2287     2300      +13     
==========================================
+ Hits         1112     1119       +7     
- Misses       1175     1181       +6     
Flag Coverage Δ
unit-tests 48.66% <63.64%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@orhun orhun closed this May 25, 2026
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.

fields for github remote not populated

3 participants