fix(web): show empty repository browse state#1380
Open
DivyamTalwar wants to merge 4 commits into
Open
Conversation
Treat zero-commit repositories as an empty root in browse tree APIs after git ls-tree fails, and render a dedicated empty-state message instead of generic tree errors. Constraint: Empty repositories have no resolvable HEAD, so git ls-tree fails before the existing empty-list UI path can run. Rejected: Adding a new service error code | the browse surfaces already accept empty tree/list payloads and this keeps the API change narrow. Confidence: high Scope-risk: narrow Directive: Keep non-empty unresolved refs on the error path; do not hide git failures unless rev-list confirms the repository has zero commits. Tested: node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/web test src/features/git/utils.test.ts src/features/git/emptyRepositoryApi.test.ts 'src/app/(app)/browse/components/emptyRepositoryPanels.test.tsx' Tested: node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/web lint Not-tested: Manual browser reproduction against a live empty remote repository.
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
WalkthroughAdds git helpers and API changes to detect empty repositories and return empty results instead of errors. The browse tree panels now render “This repository is empty” for empty repository states, with tests covering the API and UI behavior. Empty Repository Detection and UI
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Constraint: Sourcebot requires a follow-up changelog entry for every PR under the matching Unreleased section. Confidence: high Scope-risk: narrow Directive: Keep this commit scoped to the changelog entry for PR sourcebot-dev#1380. Tested: Not run; changelog-only follow-up. Not-tested: Runtime tests unchanged from the implementation commit.
Merge upstream main after sourcebot-dev#1376 changed the same Unreleased changelog block, keeping both release-note entries. Constraint: GitHub reported PR sourcebot-dev#1380 as dirty against current main.\nRejected: Rewriting the open PR branch | Avoids force-pushing an existing review branch.\nConfidence: high\nScope-risk: narrow\nDirective: This merge commit should only resolve the changelog ordering conflict.\nTested: git diff --check\nNot-tested: Targeted regression test rerun follows after the merge commit.
Preserve the empty browse state while preventing missing paths or arbitrary unresolved refs from being reported as an empty repository. The API now carries explicit empty-repository state to the tree preview and the file-tree path handling treats root-equivalent path entries consistently. Constraint: Empty repositories have no commit object, so HEAD ls-tree fails even for the legitimate default browse state. Rejected: Inferring repository emptiness from an empty tree listing | non-empty repos can return empty ls-tree output for missing pathspecs. Confidence: high Scope-risk: narrow Directive: Only downgrade ls-tree failures to empty results after confirming the repo has zero commits and the ref is HEAD or the symbolic default branch. Tested: node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/web test src/features/git/utils.test.ts src/features/git/emptyRepositoryApi.test.ts 'src/app/(app)/browse/components/emptyRepositoryPanels.test.tsx'; node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/web lint; git diff --check. Not-tested: Manual browser reproduction against a live empty remote repository.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #821
Problem
Browsing a repository with no commits falls through to generic tree-loading errors. The root tree preview calls
git ls-tree HEAD, but an empty repository has no resolvable commit object yet, so both the root preview and file tree panel showed misleading failures instead of an empty-repository state.Root cause
getFolderContentsandgetTreetreated everygit ls-treefailure as an unexpected error. For an unborn repository, a failure at the default browse ref is expected because there is no commit object yet. At the same time, emptyls-treeoutput is not enough to prove the repository is empty, because missing pathspecs in non-empty repos can also return no rows.Solution
git rev-list --count --allafter anls-treefailure.HEADor the repo's symbolic default branch.This repository is emptyin both browse tree surfaces only for confirmed empty repositories.Tests
paths: [""], and stale open paths in empty repositories.node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/web test src/features/git/utils.test.ts src/features/git/emptyRepositoryApi.test.ts 'src/app/(app)/browse/components/emptyRepositoryPanels.test.tsx'node .yarn/releases/yarn-4.7.0.cjs workspace @sourcebot/web lintgit diff --checkRisk
Low. The empty behavior only activates after
ls-treefails, the repo is confirmed to have zero commits, and the requested ref is the default empty-repo browse ref. Non-empty repositories and unresolved custom refs keep returning errors.Not tested
Manual browser reproduction against a live empty remote repository.
Summary by CodeRabbit