Skip to content

Conversation

@brendan-kellam
Copy link
Contributor

@brendan-kellam brendan-kellam commented Jan 28, 2026

Prefix refs/heads/ to the default branch for consistent searching and de-duplicate the revisions array to prevent duplicate branches/tags.

Fixes #808


Open in Cursor Open in Web

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where searching for the default branch reference would return no matches.
    • Improved branch reference normalization and deduplication in repository indexing to ensure consistent naming conventions and prevent duplicate entries during indexing operations.

✏️ Tip: You can customize this high-level summary in your review settings.

@cursor
Copy link

cursor bot commented Jan 28, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@coderabbitai
Copy link

coderabbitai bot commented Jan 28, 2026

Walkthrough

The PR fixes an issue where searching for refs/heads/<default_branch> returned no matches. It normalizes the default branch reference to include the refs/heads/ prefix, deduplicates revisions to prevent duplicates, and ensures consistent revision naming during indexing.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md
Added Fixed section documenting resolution of issue where searching for refs/heads/<default_branch> would return no matches.
Revision normalization and deduplication
packages/backend/src/repoIndexManager.ts
Normalizes default branch reference to include refs/heads/ prefix; initializes revisions from prefix-wrapped default branch or HEAD; deduplicates revisions list before indexing; ensures consistent refs/heads/... and refs/tags/... prefixes for branches and tags.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR directly fixes issue #808 by prefixing refs/heads/ to the default branch and de-duplicating revisions to enable proper searching.
Out of Scope Changes check ✅ Passed All changes are within scope: repoIndexManager.ts modifications target the core fix, and CHANGELOG.md documents the change as requested.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately summarizes the main change: fixing an issue where searching for refs/heads/<default_branch> returns no matches, which directly addresses the bug described in issue #808.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@brendan-kellam brendan-kellam marked this pull request as ready for review January 28, 2026 21:29
@github-actions

This comment has been minimized.

@brendan-kellam
Copy link
Contributor Author

@cursor add a changelog entry

@cursor
Copy link

cursor bot commented Jan 28, 2026

I've added the changelog entry for PR #809. The entry has been added under the "Unreleased" section in the "Fixed" category, documenting that the fix resolves the issue where searching for refs/heads/<default_branch> would return no matches.

The changelog entry has been committed and pushed to the branch.

View PR
Open in Cursor Open in Web

@brendan-kellam
Copy link
Contributor Author

@cursor don't make any code changes. To confirm, does this handle the case where a branch could be named heads/...? Could a branch ever be prefixed with refs/... without being refs/heads/... or refs/tags/...?

@cursor
Copy link

cursor bot commented Jan 28, 2026

Looking at the current implementation, I can answer both questions:

Question 1: Does this handle a branch named heads/...?

No, the current implementation has a potential issue. If someone literally names a branch heads/something, the code would produce refs/heads/heads/something because:

  • getLocalDefaultBranch() would return heads/something
  • The check !defaultBranch.startsWith('refs/') would be true
  • It would prepend refs/heads/ resulting in refs/heads/heads/something

This is likely a valid concern, though having a branch literally named heads/... would be unusual (but technically possible in Git).

Question 2: Could a branch be prefixed with refs/... without being refs/heads/... or refs/tags/...?

Yes, Git supports several other ref namespaces:

  • refs/remotes/... - remote tracking branches
  • refs/notes/... - Git notes
  • refs/stash - stash entries
  • refs/replace/... - replacement refs
  • Custom namespaces under refs/

The current check !defaultBranch.startsWith('refs/') would leave any of these untouched, which might not be the intended behavior.

What does getLocalDefaultBranch() actually return?

To properly assess if this is an issue, we'd need to verify what format getLocalDefaultBranch() returns - does it return just the branch name (e.g., main) or could it return a full ref path? If it only returns simple branch names, the current logic should work correctly for normal cases.

View PR
Open in Cursor Open in Web

@brendan-kellam brendan-kellam changed the title Default branch refs revisions fix(worker): Fixed issue where searching for refs/heads/<default_branch> would return no matches. Jan 28, 2026
@brendan-kellam brendan-kellam merged commit a8c26dc into main Jan 28, 2026
9 checks passed
@brendan-kellam brendan-kellam deleted the cursor/default-branch-refs-revisions-52f9 branch January 28, 2026 21:40
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.

[bug] Unable to search for refs/heads/<default_branch>

3 participants