Fix external package publish ancestry check - #365
Conversation
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughReplaced isomorphic-git ancestry check with a shell-based traversal using the DurableObject git adapter ( ChangesAncestry Checking Refactor & Test
Sequence DiagramsequenceDiagram
autonumber
participant Client as rgba(66,135,245,0.5) Client
participant RepoSession as rgba(39,174,96,0.5) RepoSessionBase
participant DOgit as rgba(231,76,60,0.5) DurableObject.git
Client->>RepoSession: publishFromExternalRef(newCommit)
RepoSession->>RepoSession: getEntitySourceById -> published_commit: commit-old
RepoSession->>DOgit: log(dir: '/session', ref: 'commit-new', depth: Infinity)
DOgit-->>RepoSession: [{oid: 'commit-new'}, {oid: 'commit-old'}]
RepoSession->>RepoSession: find ancestor == 'commit-old' in log -> true
RepoSession->>Client: return { status: 'published' }
RepoSession->>RepoSession: updateEntitySource(publishedCommit: 'commit-new')
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
🔎 Preview deployed: https://kody-pr-365.kentcdodds.workers.dev Worker: Mocks:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/worker/src/repo/repo-session-do.node.test.ts (1)
927-965: 💤 Low valueNew test looks correct; note
git.logis not reset insetCommonSessionFixturesThe test correctly uses
mockResolvedValueOnce(one call togit.login thepublishFromExternalRefpath), exercises the realpublishExternalRefSourceimplementation for integration coverage, and asserts the expected call shape.Minor hygiene:
setCommonSessionFixturesclearspull,push,updateRepoSession, andupdateEntitySource, butgit.logis left uncleaned. If a future test queues multiplemockResolvedValueOncecalls ongit.logwithout clearing, stale queued values could bleed across test boundaries. AddingmockModule.git.log.mockClear()tosetCommonSessionFixtureswould make test isolation explicit.🔧 Suggested addition to `setCommonSessionFixtures`
mockModule.git.pull.mockClear() mockModule.git.push.mockClear() + mockModule.git.log.mockClear() mockModule.updateRepoSession.mockClear() mockModule.updateEntitySource.mockClear()🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/worker/src/repo/repo-session-do.node.test.ts` around lines 927 - 965, The test-suite setup function setCommonSessionFixtures leaves mockModule.git.log mocks queued which can leak stubbed responses between tests; update setCommonSessionFixtures to call mockModule.git.log.mockClear() (or mockReset()) so that any previously queued mockResolvedValueOnce entries are cleared before each test, ensuring publishFromExternalRef and other tests get isolated git.log behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/worker/src/repo/repo-session-do.ts`:
- Around line 459-464: In isAncestorCommit replace the undocumented hardcoded
depth: -1 with a documented unlimited positive value (e.g., Infinity or
Number.POSITIVE_INFINITY) so the git.log call traverses the full history; update
the options passed in the commits = await this.git.log(...) call to use that
unlimited depth constant instead of -1 and add a brief comment referencing
parseOptionalDepth to note why negatives are disallowed and we use Infinity to
request the full history.
---
Nitpick comments:
In `@packages/worker/src/repo/repo-session-do.node.test.ts`:
- Around line 927-965: The test-suite setup function setCommonSessionFixtures
leaves mockModule.git.log mocks queued which can leak stubbed responses between
tests; update setCommonSessionFixtures to call mockModule.git.log.mockClear()
(or mockReset()) so that any previously queued mockResolvedValueOnce entries are
cleared before each test, ensuring publishFromExternalRef and other tests get
isolated git.log behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 06b096e1-951d-4830-a8cd-8e12eb36f5c2
📒 Files selected for processing (2)
packages/worker/src/repo/repo-session-do.node.test.tspackages/worker/src/repo/repo-session-do.ts
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Summary
isomorphic-gitfilesystem call that could receive an incompatible workspace filesystem shapeNumber.POSITIVE_INFINITYfor the full-history ancestry walk instead of a negative depth sentinelRoot cause
package_publish_external_pushtakes the external publish path and checks fast-forward ancestry after cloning/checking out the pushed Artifacts commit. That path calledisomorphic-git.isDescendentdirectly withWorkspaceFileSystem; in the execute/codemode callback path, isomorphic-git treated that object as a filesystem and attempted to bind missing fs methods, producingCannot read properties of undefined (reading 'bind'). The workingrepo_run_commands publishpath stays on the@cloudflare/shellgit adapter, so it did not hit the incompatible direct fs usage.Validation
npm test -- packages/worker/src/repo/repo-session-do.node.test.ts packages/worker/src/mcp/capabilities/packages/publish-external-push.node.test.tsnpm run typecheckSummary by CodeRabbit
Tests
Chores