Implement the author workflow for creating and viewing pull requests.
Tasks#
- Implement
tangled pr create --base <base-branch> --head <head-branch> --title <title> [--body <body> | --body-file <file> | -F -]command.- Warn if the branch is behind the target branch, as tangled.org has trouble with diffs when there are unmerged changes. Suggest merging the target into this branch before proceeding and confirm if the user wants to continue. Add a flag to override this behaviour and merge without checking for unmerged commits.
- Generate the
git diffpatch between the--headand--basebranches. - Gzip-compress the patch (the tangled.org web UI uploads blobs with
mimeType: "application/gzip"). - Upload the compressed patch as a blob using
com.atproto.repo.uploadBlobwithmimeType: "application/gzip". - Resolve the target repo AT-URI (e.g.
at://did:plc:.../sh.tangled.repo/<rkey>) from the git remote. - Create a
sh.tangled.repo.pullrecord usingcom.atproto.repo.createRecordwith fields:target(repo AT-URI + base branch),source(head branch + 40-char SHA),title, optionalbody,patchBlob(blob ref), andcreatedAt.
- Implement
tangled pr list [--json <fields>]command to list pull requests for the current repository.- Use
com.atproto.repo.listRecordswithcollection: "sh.tangled.repo.pull". - Output should include the pull request number, CID, title, source branch, and status.
- Use
- Implement
tangled pr view <id> [--json <fields>]command to display detailed information about a specific pull request.- Use
com.atproto.repo.getRecordfor thesh.tangled.repo.pullrecord. - Fetch associated comments using
com.atproto.repo.listRecordswithcollection: "sh.tangled.repo.pull.comment". - Dogfood the CLI by using it to create a pull request for these changes, then view the created PR to verify all data is correctly stored and retrieved.
- Use
Reference#
Example sh.tangled.repo.pull record shape (from live data):
{
"$type": "sh.tangled.repo.pull",
"title": "...",
"source": { "sha": "<40-char SHA>", "branch": "<head-branch>" },
"target": { "repo": "at://<did>/sh.tangled.repo/<rkey>", "branch": "<base-branch>" },
"createdAt": "<ISO datetime>",
"patchBlob": { "$type": "blob", "ref": { "$link": "<CID>" }, "mimeType": "application/gzip", "size": <bytes> }
}