From c2f7930597600cb84fc43853e6485c42825cb65c Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Tue, 29 Sep 2026 17:09:29 +0900 Subject: [PATCH] localinfra: include fork based PR Signed-off-by: Seongmin Lee --- localinfra/scripts/init-data.sh | 54 +++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/localinfra/scripts/init-data.sh b/localinfra/scripts/init-data.sh index 1c08e686e..3fc6329cc 100644 --- a/localinfra/scripts/init-data.sh +++ b/localinfra/scripts/init-data.sh @@ -26,6 +26,7 @@ CORE_SOURCE=https://knot1.tangled.sh/did:plc:ioighzh4jnrhybayw65gfbia # every record this script seeds, and who authors it REPO_CORE=at://$OWNER_DID/sh.tangled.repo/core REPO_EMPTY=at://$BOB_DID/sh.tangled.repo/empty-repo +REPO_CORE_FORK=at://$BOB_DID/sh.tangled.repo/core-fork ISSUE_1=at://$OWNER_DID/sh.tangled.repo.issue/3lzg6f3aia222 ISSUE_2=at://$OWNER_DID/sh.tangled.repo.issue/3lzg6guhjy222 @@ -37,6 +38,7 @@ PULL_1=at://$OWNER_DID/sh.tangled.repo.pull/3lzg7tkxvq222 PULL_2=at://$OWNER_DID/sh.tangled.repo.pull/3ms6rk5d6gk22 PULL_3=at://$OWNER_DID/sh.tangled.repo.pull/3ms6rk5d6gk33 PULL_4=at://$OWNER_DID/sh.tangled.repo.pull/3mszlqgjlzsdn +PULL_FORK=at://$BOB_DID/sh.tangled.repo.pull/3mwkc7fnrkp22 STRING_CODE=at://$OWNER_DID/sh.tangled.string/3lzg6ma4pa222 STRING_MARKDOWN=at://$OWNER_DID/sh.tangled.string/3lzg6nzdqy222 @@ -95,8 +97,9 @@ while :; do resp=$(curl -sS -w '\n%{http_code}' \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $token" \ - -d "$(jq -nc --arg source "$CORE_SOURCE" \ - '{rkey:"core", name:"core", defaultBranch:"master", source:$source}')" \ + -d "$(jq -nc --arg url "$CORE_SOURCE" \ + '{rkey:"core", name:"core", defaultBranch:"master", + source:{url:$url, kind:"fork"}}')" \ "${KNOT_URL}/xrpc/sh.tangled.repo.create") body=$(printf '%s\n' "$resp" | sed '$d') status=$(printf '%s\n' "$resp" | tail -n1) @@ -161,6 +164,36 @@ put_record "$REPO_EMPTY" "$(jq -nc \ --arg createdAt "$CREATED_AT" \ '{knot:$knot, name:"empty-repo", repoDid:$repoDid, createdAt:$createdAt}')" >/dev/null +# bob's fork of core. +token=$(service_token "$BOB_JWT" sh.tangled.repo.create "$KNOT_DID") +resp=$(curl -sS -w '\n%{http_code}' \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $token" \ + -d "$(jq -nc --arg url "https://${KNOT_HOSTNAME}/${REPO_DID}" \ + '{rkey:"core-fork", name:"core-fork", defaultBranch:"master", + source:{url:$url, kind:"fork"}}')" \ + "${KNOT_URL}/xrpc/sh.tangled.repo.create") +body=$(printf '%s\n' "$resp" | sed '$d') +status=$(printf '%s\n' "$resp" | tail -n1) +case "$status" in + 200) FORK_REPO_DID=$(printf '%s\n' "$body" | jq -er '.repoDid') ;; + 409) + FORK_REPO_DID=$(curl -fsS \ + "${PDS_URL}/xrpc/com.atproto.repo.getRecord?repo=${BOB_DID}&collection=sh.tangled.repo&rkey=core-fork" \ + | jq -er '.value.repoDid') + ;; + *) fail "repo.create core-fork: HTTP $status: $body" ;; +esac + +printf '[knot] core-fork = %s\n' "$FORK_REPO_DID" >&2 + +put_record "$REPO_CORE_FORK" "$(jq -nc \ + --arg knot "$KNOT_HOSTNAME" \ + --arg repoDid "$FORK_REPO_DID" \ + --arg source "$REPO_DID" \ + --arg createdAt "$CREATED_AT" \ + '{knot:$knot, name:"core-fork", repoDid:$repoDid, source:$source, createdAt:$createdAt}')" >/dev/null + # --- issue fixtures --- put_record "$ISSUE_1" "$(jq -nc \ @@ -378,6 +411,23 @@ MARKDOWN {head:$head3, base:$base3, createdAt:$createdAt3}, {head:$head4, base:$base4, createdAt:$createdAt4}]}')") +# a fork-based PR +keep_commit "$FORK_REPO_DID" "$PULL_HEAD_2" "$PULL_FORK" + +put_record "$PULL_FORK" "$(jq -nc \ + --arg source "$FORK_REPO_DID" \ + --arg target "$REPO_DID" \ + --arg title 'ref based PR from a fork' \ + --arg body 'opened from core-fork, so source and target are different repos' \ + --arg head "$PULL_HEAD_2" \ + --arg base "$PULL_BASE" \ + --arg createdAt '2025-09-22T10:45:35Z' \ + '{title:$title, body:$body, createdAt:$createdAt, + source:{repo:$source, branch:"sl/ref-based-pr"}, + target:{repo:$target, branch:"master"}, + rounds:[], + versions:[{head:$head, base:$base, createdAt:$createdAt}]}')" >/dev/null + # --- string fixtures --- STRING_CODE_CID=$(put_record "$STRING_CODE" "$(jq -nc \ -- 2.51.2