Skip to content

feat: ez fork command for fork-based workflow#3

Open
dezren39 wants to merge 11 commits into
feat/worktree-opsfrom
feat/fork
Open

feat: ez fork command for fork-based workflow#3
dezren39 wants to merge 11 commits into
feat/worktree-opsfrom
feat/fork

Conversation

@dezren39
Copy link
Copy Markdown
Owner

@dezren39 dezren39 commented Apr 12, 2026

Adds fork-based workflow support: ez fork command, --repo/--remote flags on push/submit, cross-fork PR detection, and per-branch push remote/PR repo inheritance through the stack.

Changes

  • ez fork — forks upstream via gh, adds remote, configures stack.json
    • --remote — custom remote name (default: fork)
    • --from user — add someone else's fork
  • --repo flag on ez push/ez submit — target a specific repo for PR creation
    • Stored per-branch on first use; children inherit from parent
    • Smart shorthand resolution: remote names, owners, or full owner/repo
  • --remote flag on ez push/ez submit — push to a specific git remote
    • Stored per-branch on first use; children inherit via effective_push_remote
  • ez config set branch.<name>.pr — smart parsing of PR URLs, #N, owner/repo#N
  • ez config set branch.<name>.push_remote — per-branch push remote override
  • Cross-fork PR detectionget_pr_status_in_repo retries with fork-prefixed head (dezren39:feat/config) when bare branch name fails
  • Stack inheritanceeffective_push_remote and effective_pr_repo walk parent chain for push remote and PR repo resolution
  • Git helpers: remote_exists, remote_url, remote_owner, add_remote, rename_branch, update_branch_ref
  • GitHub helpers: repo_name_from_url, resolve_repo_shorthand, cross_fork_head

Commits (11)

  • 7419588 feat: add ez fork command for fork-based workflow
  • a554bd9 test: add remote_exists, add_remote, and remote_url git helper tests
  • 8eaf887 feat: add --repo flag to push and submit for per-command PR target override
  • 2fa335e feat: persist pr_repo per-branch so future pushes reuse the target repo
  • a8d9081 fix: pr_repo resolution order — stored beats config, only store on explicit --repo
  • ce24126 feat: wire pr_repo through all gh calls, add cross-fork head prefix and per-branch push_remote
  • 6668c1e feat: ez config branch attr detection, --branch flag, pr/pr_repo/pr_number smart parsing
  • c547826 feat: add resolve_repo_shorthand for smart repo resolution from remotes, owners, and names
  • ca3a08e feat: make all PR commands fork-aware with effective_pr_repo helper
  • d31322e feat: walk stack for push remote and PR repo inheritance
  • c9f9b72 chore: remove unused effective_remote method

Resolves rohoswagger#4


Stack (this PR is 4 of 5):

  1. feat/config (rohoswagger#9)
  2. feat/preflight (dezren39#1)
  3. feat/worktree-ops (dezren39#2)
  4. → feat/fork ← you are here (dezren39#3)
  5. feat/local-merge (dezren39#4)

Adds ez fork to configure push remote and PR target repo. gh pr create now passes --repo when state.repo is set, enabling fork workflows where you push to your fork but PRs target upstream.
…nd per-branch push_remote

Add _in_repo variants for all gh PR operations (view/edit/base/body/ready/merge).
Add cross_fork_head() to compute owner:branch head for cross-fork PRs.
Add BranchMeta.push_remote field for per-branch push remote override.
Add default_remote(), tracking_remote(), remote_owner() git helpers.
Add StackState.effective_push_remote() chain: branch.push_remote > git tracking > state.remote > git default.
Wire effective_repo through push_or_update_pr for all gh calls.
Use effective_push_remote in push::run and submit::run.
…umber smart parsing

Add --branch flag to config get/set (bare --branch = current branch).
Auto-detect branch attrs (pr, pr_repo, pr_number, push_remote, scope, scope_mode, parent).
Support branch. prefix: ez config branch.pr_repo owner/repo.
Smart pr parser: 123, #123, owner/repo#123, URL all work.
pr_repo prepends current owner if no slash (except pure numbers).
remote --branch becomes per-branch push_remote.
20 new tests for parsing, classification, and branch value set/get.
…es, owners, and names

Resolve bare names like 'asd#123' by checking:
1. Git remote named 'asd' → extract owner/repo from URL
2. Remote whose URL owner matches 'asd' → use that remote's repo
3. Prepend current repo owner → currentowner/asd
4. Return as-is if unresolvable
Wire into config pr and pr_repo parsing (replaces local normalize_repo).
Pure numbers bypass resolution (literal repo names).
4 new tests for shorthand resolution.
Add StackState::effective_pr_repo() to resolve per-branch PR target repo (branch.pr_repo > state.repo > None). Wire _in_repo variants into all 12 remaining command files: merge, pr_edit, draft, pr_view, delete, move_branch, status, log, pr_link, checkout, list, and sync. Add _in_repo variants for batch functions (get_all_pr_statuses, get_all_ci_statuses, get_ci_status). Normalize --repo via resolve_repo_shorthand in push.rs. 240 tests passing.
effective_push_remote now walks up the parent chain before falling back to git tracking remote, default branch remote, state.remote, or git default. effective_pr_repo derives from parent push remote URL (where the base ref lives) instead of parent pr_repo. Tests use CwdGuard with temp repos to isolate from real remotes.
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