Skip to content

fix(container): sync plan-to-git against upstream repo#419

Merged
skulidropek merged 4 commits into
mainfrom
issue-417
Jun 17, 2026
Merged

fix(container): sync plan-to-git against upstream repo#419
skulidropek merged 4 commits into
mainfrom
issue-417

Conversation

@skulidropek

@skulidropek skulidropek commented Jun 17, 2026

Copy link
Copy Markdown
Member

Summary

  • Pin generated containers to plan-to-git commit debc5f5b08a02f9038d7df8938cf72a6ec24a22a from feat(cli): support explicit GitHub repo target plan-to-git#9.
  • Use the new PLAN_TO_GIT_REPO target boundary for every generated plan-to-git invocation.
  • Resolve the target from upstream first and fall back to origin, while leaving local git origin/state identity unchanged.
  • Remove the previous scoped url.<upstream>.insteadOf=<origin> workaround from the generated hook runner and tests.

Depends on: ProverCoderAI/plan-to-git#9

Proof of fix

  • Причина: fork containers push to origin but must post plan comments to the upstream PR repository; without an explicit target, plan-to-git can only infer the fork from local git context.
  • Решение: plan-to-git now exposes --repo / PLAN_TO_GIT_REPO for GitHub PR/comment targeting, and docker-git passes the upstream/base repo into that API instead of rewriting git config.
  • Доказательство: local wrapper tests assert that normal and fork-origin post-push flows call plan-to-git with PLAN_TO_GIT_REPO=org/repo, including sync --pr 375.

Validation

  • bun --cwd packages/container test tests/core/git-post-push-wrapper.test.ts tests/core/templates.test.ts
  • cd packages/container && bun run typecheck
  • cd packages/container && bun run build
  • cd packages/container && bun run lint

@skulidropek

Copy link
Copy Markdown
Member Author

Agent Plan Update

Branch: issue-417 at 4349caf.

1. Plan

Source: codex - Captured: 2026-06-17T12:58:27.447Z

Fix Issue #417: plan-to-git Sync Uses Fork Repo For Base PR

Summary

  • Root cause: generated hooks call plan-to-git sync --pr <number>, but the installed plan-to-git discovers repo_slug from origin. In fork workspaces, origin is the fork while the PR exists in upstream, so comment creation targets the wrong repo and returns GitHub 404.
  • Fix: run every generated plan-to-git invocation under a scoped Git URL rewrite that makes only the child process see origin as the base repo when upstream exists. Do not mutate .git/config.

Key Changes

  • Add shared GitHub remote helper template for docker_git_github_repo_from_remote_url and docker_git_github_repo_from_remote; reuse it from PR ensure and plan sync templates.
  • Add docker_git_plan_to_git_run bash helper in generated plan hooks:
    • resolves base_repo as upstream || origin;
    • reads real origin_url;
    • if both exist, calls env GIT_CONFIG_COUNT=... GIT_CONFIG_KEY_N=url.https://github.com/${base_repo}.git.insteadOf GIT_CONFIG_VALUE_N=${origin_url} plan-to-git "$@";
    • falls back to plain plan-to-git "$@" when repo data is unavailable.
  • Replace direct generated calls with docker_git_plan_to_git_run for:
    • hook --source codex
    • hook --source claude
    • import-codex --no-sync
    • import-claude --no-sync
    • sync --pr "$pr_number"
    • fallback sync
  • Preserve existing public behavior and interfaces: no new CLI flags, no new required env vars, existing skip env vars still work.

Test Plan

  • Update packages/container/tests/core/git-post-push-wrapper.test.ts:
    • fake plan-to-git sync --help returns --pr <PR> without polluting normal command logs;
    • fake plan-to-git logs scoped GIT_CONFIG_* values for assertions.
  • Add regression test: fork origin, base upstream, existing PR, DOCKER_GIT_PR_NUMBER=375.
    • Assert gh pr list targets org/repo with me:issue-375.
    • Assert no duplicate PR is created.
    • Assert imports and sync --pr 375 run with url.https://github.com/org/repo.git.insteadOf=https://github.com/me/repo.git.
    • Assert session backup still runs after plan sync.
  • Update packages/container/tests/core/templates.test.ts to assert generated hooks contain and use the scoped runner.

Verification

  • First install deps if still absent: bun install --frozen-lockfile.
  • Run:
    • bun run --cwd packages/container test -- tests/core/git-post-push-wrapper.test.ts tests/core/templates.test.ts
    • bun run --filter @prover-coder-ai/docker-git-container typecheck
    • bun run --filter @prover-coder-ai/docker-git-container test

Assumptions

  • The installed plan-to-git revision remains f60fbe71131854be4c6c1d9fb79abafd2dd6949b, whose sync CLI supports --pr but not --repo.
  • The fix should stay in docker-git generated hooks rather than requiring a new plan-to-git release.
  • Current workspace has no node_modules; the baseline test could not start because vitest is not installed.

@skulidropek

skulidropek commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

AI Session Backup

Commit: 4349caf
Status: success
Files: 4 (4.90 MB)
Links: README | Manifest

git status

On branch issue-417
Your branch is up to date with 'origin/issue-417'.

nothing to commit, working tree clean

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@skulidropek, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 5 minutes and 15 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 669f9155-946c-4a71-922e-cf701fc41ff5

📥 Commits

Reviewing files that changed from the base of the PR and between 4581997 and 6637e88.

📒 Files selected for processing (6)
  • packages/container/src/core/templates-entrypoint/github-remotes.ts
  • packages/container/src/core/templates-entrypoint/plan-to-git.ts
  • packages/container/src/core/templates-entrypoint/post-push-pr.ts
  • packages/container/src/core/templates/dockerfile-prelude.ts
  • packages/container/tests/core/git-post-push-wrapper.test.ts
  • packages/container/tests/core/templates.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-417

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.

@skulidropek

skulidropek commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

AI Session Backup

Commit: 687d959
Status: success
Files: 5 (6.41 MB)
Links: README | Manifest

git status

On branch issue-417
Your branch is up to date with 'origin/issue-417'.

nothing to commit, working tree clean

@skulidropek

skulidropek commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

AI Session Backup

Commit: 3b9da61
Status: success
Files: 5 (6.70 MB)
Links: README | Manifest

git status

On branch issue-417
Your branch is up to date with 'origin/issue-417'.

nothing to commit, working tree clean

@skulidropek

skulidropek commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

AI Session Backup

Commit: 6637e88
Status: success
Files: 5 (7.48 MB)
Links: README | Manifest

git status

On branch issue-417
Your branch is up to date with 'origin/issue-417'.

nothing to commit, working tree clean

@skulidropek skulidropek merged commit 797d1ea into main Jun 17, 2026
17 of 20 checks passed
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.

1 participant