Skip to content

feat: link existing GitHub branches to tasks (POST /branches/link) - #17

Closed
Anshulgada wants to merge 3 commits into
Paca-AI:masterfrom
Anshulgada:feat/link-existing-branch
Closed

feat: link existing GitHub branches to tasks (POST /branches/link)#17
Anshulgada wants to merge 3 commits into
Paca-AI:masterfrom
Anshulgada:feat/link-existing-branch

Conversation

@Anshulgada

Copy link
Copy Markdown

Summary

Adds a link-only branch endpoint mirroring POST .../pull-requests/link.

  • POST /projects/:projectId/tasks/:taskId/branches/link — verify branch exists on GitHub, insert into github_task_branches (supports one branch → many tasks)
  • github_link_branch_to_task MCP tool
  • Optional GitHub ref check via branchExists() before linking

Fixes IDE/agent workflows where the branch already exists and POST /branches fails with Reference already exists.

Closes #16

Test plan

  • go test ./... in backend/
  • Link existing branch to task via API
  • Link same branch to a second task
  • 404 when branch name does not exist on GitHub
  • 409 when already linked to same task

…ith tasks

Mirrors pull-requests/link: verifies the branch ref on GitHub, inserts into
github_task_branches, and exposes github_link_branch_to_task MCP tool.

Fixes linking IDE-created branches without calling GitHub create (Reference
already exists). Closes Paca-AI#16.
Copilot AI review requested due to automatic review settings July 30, 2026 11:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Branch names like fix/foo were split into extra path segments when
building GET .../git/ref/heads/{branch}, causing fetch failures that
looked like domain allowlist errors. Encode owner, repo, and branch
ref segments with url.PathEscape.

Adds unit tests for ghBranchHeadRefURL and link-route validation.
@Anshulgada

Copy link
Copy Markdown
Author

Update: branch names with / fixed (c915573)

GitHub ref URLs now URL-encode the branch segment (fix/foo.../heads/fix%2Ffoo). Verified locally: linking fix/upload-pipeline-t8-investigation hits GitHub successfully (409 when already linked, not 502).

Workaround used before this fix: ~/paca/scripts/link-github-branch.sh — tries the plugin API first; on failure falls back to a direct Postgres insert into github_task_branches (no GitHub ref check). Used successfully for SQA2-18 during rollout.

Replace org-internal repo/branch names in URL tests with public
projects (torvalds/linux, golang/go, etc.). Add table-driven slash
encoding cases. Add link/create branch 400-path validation tests.
@Anshulgada
Anshulgada force-pushed the feat/link-existing-branch branch from c34a513 to 8395594 Compare July 31, 2026 06:13
@Anshulgada

Copy link
Copy Markdown
Author

Superseded by a clean single-commit PR with the same feature (no messy commit history).

@Anshulgada Anshulgada closed this Jul 31, 2026
@Anshulgada
Anshulgada deleted the feat/link-existing-branch branch July 31, 2026 06:54
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.

Add POST /tasks/:taskId/branches/link to link existing branches without GitHub create

2 participants