From b6f5f5806dce8cb7c9bb4d6f4080fce03ee7c8a6 Mon Sep 17 00:00:00 2001 From: dawn Date: Wed, 16 Sep 2026 03:49:24 +0300 Subject: [PATCH] lexicons/repo: add source kind to create and content to describeRepo Signed-off-by: dawn --- api/tangled/repocreate.go | 12 ++++++++++-- api/tangled/repodescribeRepo.go | 6 +++++- appview/repo/repo.go | 9 ++++++--- knotserver/xrpc/create_repo.go | 4 ++-- lexicons/repo/create.json | 27 +++++++++++++++++++++++++-- lexicons/repo/describeRepo.json | 14 ++++++++++++++ 6 files changed, 62 insertions(+), 10 deletions(-) diff --git a/api/tangled/repocreate.go b/api/tangled/repocreate.go index 94b3c1cb8..583d3dbc4 100644 --- a/api/tangled/repocreate.go +++ b/api/tangled/repocreate.go @@ -24,8 +24,8 @@ type RepoCreate_Input struct { RepoDid *string `json:"repoDid,omitempty" cborgen:"repoDid,omitempty"` // rkey: Rkey of the repository record Rkey string `json:"rkey" cborgen:"rkey"` - // source: A source URL to clone from, populate this when forking or importing a repository. - Source *string `json:"source,omitempty" cborgen:"source,omitempty"` + // source: A source to clone from, populate this when forking or importing a repository. + Source *RepoCreate_Source `json:"source,omitempty" cborgen:"source,omitempty"` } // RepoCreate_Output is the output of a sh.tangled.repo.create call. @@ -35,6 +35,14 @@ type RepoCreate_Output struct { RepoDid *string `json:"repoDid,omitempty" cborgen:"repoDid,omitempty"` } +// RepoCreate_Source is a "source" in the sh.tangled.repo.create schema. +type RepoCreate_Source struct { + // kind: fork tracks the source as upstream; import is a one-time copy. + Kind string `json:"kind" cborgen:"kind"` + // url: Git URL to clone from + Url string `json:"url" cborgen:"url"` +} + // RepoCreate calls the XRPC method "sh.tangled.repo.create". func RepoCreate(ctx context.Context, c util.LexClient, input *RepoCreate_Input) (*RepoCreate_Output, error) { var out RepoCreate_Output diff --git a/api/tangled/repodescribeRepo.go b/api/tangled/repodescribeRepo.go index 260525311..c4436cdc8 100644 --- a/api/tangled/repodescribeRepo.go +++ b/api/tangled/repodescribeRepo.go @@ -16,9 +16,13 @@ const ( // RepoDescribeRepo_Output is the output of a sh.tangled.repo.describeRepo call. type RepoDescribeRepo_Output struct { + // content: Status of the clone from source. Omitted if not created from a source. + Content *string `json:"content,omitempty" cborgen:"content,omitempty"` // ownerDid: DID of the current owner according to the knot. OwnerDid string `json:"ownerDid" cborgen:"ownerDid"` - RepoDid string `json:"repoDid" cborgen:"repoDid"` + // reason: Reason for partial or failed content. + Reason *string `json:"reason,omitempty" cborgen:"reason,omitempty"` + RepoDid string `json:"repoDid" cborgen:"repoDid"` // rkey: Current rkey of the sh.tangled.repo record tracked by this knot Rkey string `json:"rkey" cborgen:"rkey"` } diff --git a/appview/repo/repo.go b/appview/repo/repo.go index f29512b45..1035ef427 100644 --- a/appview/repo/repo.go +++ b/appview/repo/repo.go @@ -1521,9 +1521,12 @@ func (rp *Repo) ForkRepo(w http.ResponseWriter, r *http.Request) { } forkInput := &tangled.RepoCreate_Input{ - Rkey: rkey, - Name: rkey, - Source: &forkSourceUrl, + Rkey: rkey, + Name: rkey, + Source: &tangled.RepoCreate_Source{ + Url: forkSourceUrl, + Kind: "fork", + }, } createResp, err := tangled.RepoCreate( r.Context(), diff --git a/knotserver/xrpc/create_repo.go b/knotserver/xrpc/create_repo.go index 6db0271b3..c9d73741d 100644 --- a/knotserver/xrpc/create_repo.go +++ b/knotserver/xrpc/create_repo.go @@ -203,8 +203,8 @@ func (h *Xrpc) CreateRepo(w http.ResponseWriter, r *http.Request) { } } - if data.Source != nil && *data.Source != "" { - err = git.ForkWithSandbox(repoPath, *data.Source, h.Config, h.Sandbox) + if data.Source != nil && data.Source.Url != "" { + err = git.ForkWithSandbox(repoPath, data.Source.Url, h.Config, h.Sandbox) if err != nil { l.Error("forking repo", "error", err.Error()) cleanupAll() diff --git a/lexicons/repo/create.json b/lexicons/repo/create.json index 3b54f6919..fa10be44b 100644 --- a/lexicons/repo/create.json +++ b/lexicons/repo/create.json @@ -28,8 +28,9 @@ "description": "Default branch to push to" }, "source": { - "type": "string", - "description": "A source URL to clone from, populate this when forking or importing a repository." + "type": "ref", + "ref": "#source", + "description": "A source to clone from, populate this when forking or importing a repository." }, "repoDid": { "type": "string", @@ -55,6 +56,28 @@ } } } + }, + "source": { + "type": "object", + "required": [ + "url", + "kind" + ], + "properties": { + "url": { + "type": "string", + "format": "uri", + "description": "Git URL to clone from" + }, + "kind": { + "type": "string", + "knownValues": [ + "fork", + "import" + ], + "description": "fork tracks the source as upstream; import is a one-time copy." + } + } } } } diff --git a/lexicons/repo/describeRepo.json b/lexicons/repo/describeRepo.json index 96a0f6439..a814a6e55 100644 --- a/lexicons/repo/describeRepo.json +++ b/lexicons/repo/describeRepo.json @@ -35,6 +35,20 @@ "type": "string", "format": "record-key", "description": "Current rkey of the sh.tangled.repo record tracked by this knot" + }, + "content": { + "type": "string", + "knownValues": [ + "fetching", + "present", + "partial", + "failed" + ], + "description": "Status of the clone from source. Omitted if not created from a source." + }, + "reason": { + "type": "string", + "description": "Reason for partial or failed content." } } } -- 2.51.2