···
···
comatproto "github.com/bluesky-social/indigo/api/atproto"
lexutil "github.com/bluesky-social/indigo/lex/util"
"tangled.sh/tangled.sh/core/api/tangled"
"tangled.sh/tangled.sh/core/appview/commitverify"
"tangled.sh/tangled.sh/core/appview/config"
···
xrpcclient "tangled.sh/tangled.sh/core/appview/xrpcclient"
"tangled.sh/tangled.sh/core/eventconsumer"
"tangled.sh/tangled.sh/core/idresolver"
-
"tangled.sh/tangled.sh/core/knotclient"
"tangled.sh/tangled.sh/core/patchutil"
"tangled.sh/tangled.sh/core/rbac"
"tangled.sh/tangled.sh/core/tid"
···
-
if rp.config.Core.Dev {
-
url := fmt.Sprintf("%s://%s/%s/%s/archive/%s.tar.gz", uri, f.Knot, f.OwnerDid(), f.Name, url.PathEscape(refParam))
-
http.Redirect(w, r, url, http.StatusFound)
func (rp *Repo) RepoLog(w http.ResponseWriter, r *http.Request) {
···
ref := chi.URLParam(r, "ref")
-
us, err := knotclient.NewUnsignedClient(f.Knot, rp.config.Core.Dev)
-
log.Println("failed to create unsigned client", err)
-
repolog, err := us.Log(f.OwnerDid(), f.Name, ref, page)
-
log.Println("failed to reach knotserver", err)
-
tagResult, err := us.Tags(f.OwnerDid(), f.Name)
-
log.Println("failed to reach knotserver", err)
tagMap := make(map[string][]string)
-
for _, tag := range tagResult.Tags {
-
hash = tag.Tag.Target.String()
-
tagMap[hash] = append(tagMap[hash], tag.Name)
-
branchResult, err := us.Branches(f.OwnerDid(), f.Name)
-
log.Println("failed to reach knotserver", err)
-
for _, branch := range branchResult.Branches {
-
tagMap[hash] = append(tagMap[hash], branch.Name)
user := rp.oauth.GetUser(r)
-
emailToDidMap, err := db.GetEmailToDid(rp.db, uniqueEmails(repolog.Commits), true)
log.Println("failed to fetch email to did mapping", err)
-
vc, err := commitverify.GetVerifiedObjectCommits(rp.db, emailToDidMap, repolog.Commits)
···
repoInfo := f.RepoInfo(user)
-
for _, c := range repolog.Commits {
shas = append(shas, c.Hash.String())
pipelines, err := getPipelineStatuses(rp.db, repoInfo, shas)
···
-
RepoLogResponse: *repolog,
EmailToDidOrHandle: emailToDidOrHandle(rp, emailToDidMap),
···
ref := chi.URLParam(r, "ref")
-
if !rp.config.Core.Dev {
var diffOpts types.DiffOpts
if d := r.URL.Query().Get("diff"); d == "split" {
···
-
resp, err := http.Get(fmt.Sprintf("%s://%s/%s/%s/commit/%s", protocol, f.Knot, f.OwnerDid(), f.Repo.Name, ref))
-
log.Println("failed to reach knotserver", err)
-
body, err := io.ReadAll(resp.Body)
-
log.Printf("Error reading response body: %v", err)
var result types.RepoCommitResponse
-
err = json.Unmarshal(body, &result)
-
log.Println("failed to parse response:", err)
···
ref := chi.URLParam(r, "ref")
treePath := chi.URLParam(r, "*")
-
if !rp.config.Core.Dev {
// if the tree path has a trailing slash, let's strip it
treePath = strings.TrimSuffix(treePath, "/")
-
resp, err := http.Get(fmt.Sprintf("%s://%s/%s/%s/tree/%s/%s", protocol, f.Knot, f.OwnerDid(), f.Repo.Name, ref, treePath))
-
log.Println("failed to reach knotserver", err)
-
// uhhh so knotserver returns a 500 if the entry isn't found in
-
// the requested tree path, so let's stick to not-OK here.
-
// we can fix this once we build out the xrpc apis for these operations.
-
if resp.StatusCode != http.StatusOK {
-
body, err := io.ReadAll(resp.Body)
-
log.Printf("Error reading response body: %v", err)
-
var result types.RepoTreeResponse
-
err = json.Unmarshal(body, &result)
-
log.Println("failed to parse response:", err)
// redirects tree paths trying to access a blob; in this case the result.Files is unpopulated,
···
-
us, err := knotclient.NewUnsignedClient(f.Knot, rp.config.Core.Dev)
-
log.Println("failed to create unsigned client", err)
-
result, err := us.Tags(f.OwnerDid(), f.Name)
-
log.Println("failed to reach knotserver", err)
···
rp.pages.RepoTags(w, pages.RepoTagsParams{
RepoInfo: f.RepoInfo(user),
-
RepoTagsResponse: *result,
ArtifactMap: artifactMap,
DanglingArtifacts: danglingArtifacts,
···
-
us, err := knotclient.NewUnsignedClient(f.Knot, rp.config.Core.Dev)
-
log.Println("failed to create unsigned client", err)
-
result, err := us.Branches(f.OwnerDid(), f.Name)
-
log.Println("failed to reach knotserver", err)
···
rp.pages.RepoBranches(w, pages.RepoBranchesParams{
RepoInfo: f.RepoInfo(user),
-
RepoBranchesResponse: *result,
···
ref := chi.URLParam(r, "ref")
filePath := chi.URLParam(r, "*")
-
resp, err := http.Get(fmt.Sprintf("%s://%s/%s/%s/blob/%s/%s", protocol, f.Knot, f.OwnerDid(), f.Repo.Name, ref, filePath))
-
log.Println("failed to reach knotserver", err)
-
if resp.StatusCode == http.StatusNotFound {
-
body, err := io.ReadAll(resp.Body)
-
log.Printf("Error reading response body: %v", err)
-
var result types.RepoBlobResponse
-
err = json.Unmarshal(body, &result)
-
log.Println("failed to parse response:", err)
var breadcrumbs [][]string
breadcrumbs = append(breadcrumbs, []string{f.Name, fmt.Sprintf("/%s/tree/%s", f.OwnerSlashRepo(), ref)})
···
-
if markup.GetFormat(result.Path) == markup.FormatMarkdown {
showRendered = r.URL.Query().Get("code") != "true"
···
-
ext := strings.ToLower(filepath.Ext(result.Path))
case ".jpg", ".jpeg", ".png", ".gif", ".svg", ".webp":
···
-
// fetch the actual binary content like in RepoBlobRaw
-
blobURL := fmt.Sprintf("%s://%s/%s/%s/raw/%s/%s", protocol, f.Knot, f.OwnerDid(), f.Name, ref, filePath)
contentSrc = markup.GenerateCamoURL(rp.config.Camo.Host, rp.config.Camo.SharedSecret, blobURL)
user := rp.oauth.GetUser(r)
rp.pages.RepoBlob(w, pages.RepoBlobParams{
-
RepoInfo: f.RepoInfo(user),
-
RepoBlobResponse: result,
-
BreadCrumbs: breadcrumbs,
-
ShowRendered: showRendered,
-
RenderToggle: renderToggle,
-
Unsupported: unsupported,
-
ContentSrc: contentSrc,
···
ref := chi.URLParam(r, "ref")
filePath := chi.URLParam(r, "*")
-
blobURL := fmt.Sprintf("%s://%s/%s/%s/raw/%s/%s", protocol, f.Knot, f.OwnerDid(), f.Repo.Name, ref, filePath)
req, err := http.NewRequest("GET", blobURL, nil)
···
-
// Safely serve content based on type
if strings.HasPrefix(contentType, "text/") || isTextualMimeType(contentType) {
-
// Serve all textual content as text/plain for security
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
} else if strings.HasPrefix(contentType, "image/") || strings.HasPrefix(contentType, "video/") {
-
// Serve images and videos with their original content type
w.Header().Set("Content-Type", contentType)
-
// Block potentially dangerous content types
w.WriteHeader(http.StatusUnsupportedMediaType)
w.Write([]byte("unsupported content type"))
···
-
for _, t := range textualTypes {
// modify the spindle configured for this repo
···
f, err := rp.repoResolver.Resolve(r)
user := rp.oauth.GetUser(r)
-
us, err := knotclient.NewUnsignedClient(f.Knot, rp.config.Core.Dev)
-
log.Println("failed to create unsigned client", err)
-
result, err := us.Branches(f.OwnerDid(), f.Name)
-
log.Println("failed to reach knotserver", err)
···
-
us, err := knotclient.NewUnsignedClient(f.Knot, rp.config.Core.Dev)
-
log.Printf("failed to create unsigned client for %s", f.Knot)
-
result, err := us.Branches(f.OwnerDid(), f.Name)
rp.pages.Notice(w, "compare-error", "Failed to produce comparison. Try again later.")
-
log.Println("failed to reach knotserver", err)
-
branches := result.Branches
···
-
tags, err := us.Tags(f.OwnerDid(), f.Name)
rp.pages.Notice(w, "compare-error", "Failed to produce comparison. Try again later.")
-
log.Println("failed to reach knotserver", err)
···
-
us, err := knotclient.NewUnsignedClient(f.Knot, rp.config.Core.Dev)
-
log.Printf("failed to create unsigned client for %s", f.Knot)
-
branches, err := us.Branches(f.OwnerDid(), f.Name)
rp.pages.Notice(w, "compare-error", "Failed to produce comparison. Try again later.")
-
log.Println("failed to reach knotserver", err)
-
tags, err := us.Tags(f.OwnerDid(), f.Name)
rp.pages.Notice(w, "compare-error", "Failed to produce comparison. Try again later.")
-
log.Println("failed to reach knotserver", err)
-
formatPatch, err := us.Compare(f.OwnerDid(), f.Name, base, head)
rp.pages.Notice(w, "compare-error", "Failed to produce comparison. Try again later.")
-
log.Println("failed to compare", err)
diff := patchutil.AsNiceDiff(formatPatch.Patch, base)
repoinfo := f.RepoInfo(user)
···
···
comatproto "github.com/bluesky-social/indigo/api/atproto"
lexutil "github.com/bluesky-social/indigo/lex/util"
+
indigoxrpc "github.com/bluesky-social/indigo/xrpc"
"tangled.sh/tangled.sh/core/api/tangled"
"tangled.sh/tangled.sh/core/appview/commitverify"
"tangled.sh/tangled.sh/core/appview/config"
···
xrpcclient "tangled.sh/tangled.sh/core/appview/xrpcclient"
"tangled.sh/tangled.sh/core/eventconsumer"
"tangled.sh/tangled.sh/core/idresolver"
"tangled.sh/tangled.sh/core/patchutil"
"tangled.sh/tangled.sh/core/rbac"
"tangled.sh/tangled.sh/core/tid"
···
+
if !rp.config.Core.Dev {
+
host := fmt.Sprintf("%s://%s", scheme, f.Knot)
+
xrpcc := &indigoxrpc.Client{
+
repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name)
+
archiveBytes, err := tangled.RepoArchive(r.Context(), xrpcc, "tar.gz", "", refParam, repo)
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+
log.Println("failed to call XRPC repo.archive", xrpcerr)
+
// Set headers for file download
+
filename := fmt.Sprintf("%s-%s.tar.gz", f.Name, refParam)
+
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))
+
w.Header().Set("Content-Type", "application/gzip")
+
w.Header().Set("Content-Length", fmt.Sprintf("%d", len(archiveBytes)))
+
// Write the archive data directly
func (rp *Repo) RepoLog(w http.ResponseWriter, r *http.Request) {
···
ref := chi.URLParam(r, "ref")
+
if !rp.config.Core.Dev {
+
host := fmt.Sprintf("%s://%s", scheme, f.Knot)
+
xrpcc := &indigoxrpc.Client{
+
// Convert page number to cursor (offset)
+
offset := (page - 1) * int(limit)
+
cursor = strconv.Itoa(offset)
+
repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name)
+
xrpcBytes, err := tangled.RepoLog(r.Context(), xrpcc, cursor, limit, "", ref, repo)
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+
log.Println("failed to call XRPC repo.log", xrpcerr)
+
var xrpcResp types.RepoLogResponse
+
if err := json.Unmarshal(xrpcBytes, &xrpcResp); err != nil {
+
log.Println("failed to decode XRPC response", err)
+
tagBytes, err := tangled.RepoTags(r.Context(), xrpcc, "", 0, repo)
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+
log.Println("failed to call XRPC repo.tags", xrpcerr)
tagMap := make(map[string][]string)
+
var tagResp types.RepoTagsResponse
+
if err := json.Unmarshal(tagBytes, &tagResp); err == nil {
+
for _, tag := range tagResp.Tags {
+
tagMap[tag.Hash] = append(tagMap[tag.Hash], tag.Name)
+
branchBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, repo)
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+
log.Println("failed to call XRPC repo.branches", xrpcerr)
+
if branchBytes != nil {
+
var branchResp types.RepoBranchesResponse
+
if err := json.Unmarshal(branchBytes, &branchResp); err == nil {
+
for _, branch := range branchResp.Branches {
+
tagMap[branch.Hash] = append(tagMap[branch.Hash], branch.Name)
user := rp.oauth.GetUser(r)
+
emailToDidMap, err := db.GetEmailToDid(rp.db, uniqueEmails(xrpcResp.Commits), true)
log.Println("failed to fetch email to did mapping", err)
+
vc, err := commitverify.GetVerifiedObjectCommits(rp.db, emailToDidMap, xrpcResp.Commits)
···
repoInfo := f.RepoInfo(user)
+
for _, c := range xrpcResp.Commits {
shas = append(shas, c.Hash.String())
pipelines, err := getPipelineStatuses(rp.db, repoInfo, shas)
···
+
RepoLogResponse: xrpcResp,
EmailToDidOrHandle: emailToDidOrHandle(rp, emailToDidMap),
···
ref := chi.URLParam(r, "ref")
var diffOpts types.DiffOpts
if d := r.URL.Query().Get("diff"); d == "split" {
···
+
if !rp.config.Core.Dev {
+
host := fmt.Sprintf("%s://%s", scheme, f.Knot)
+
xrpcc := &indigoxrpc.Client{
+
repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name)
+
xrpcBytes, err := tangled.RepoDiff(r.Context(), xrpcc, ref, repo)
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+
log.Println("failed to call XRPC repo.diff", xrpcerr)
var result types.RepoCommitResponse
+
if err := json.Unmarshal(xrpcBytes, &result); err != nil {
+
log.Println("failed to decode XRPC response", err)
···
ref := chi.URLParam(r, "ref")
treePath := chi.URLParam(r, "*")
// if the tree path has a trailing slash, let's strip it
treePath = strings.TrimSuffix(treePath, "/")
+
if !rp.config.Core.Dev {
+
host := fmt.Sprintf("%s://%s", scheme, f.Knot)
+
xrpcc := &indigoxrpc.Client{
+
repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name)
+
xrpcResp, err := tangled.RepoTree(r.Context(), xrpcc, treePath, ref, repo)
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+
log.Println("failed to call XRPC repo.tree", xrpcerr)
+
// Convert XRPC response to internal types.RepoTreeResponse
+
files := make([]types.NiceTree, len(xrpcResp.Files))
+
for i, xrpcFile := range xrpcResp.Files {
+
file := types.NiceTree{
+
Size: int64(xrpcFile.Size),
+
IsFile: xrpcFile.Is_file,
+
IsSubtree: xrpcFile.Is_subtree,
+
// Convert last commit info if present
+
if xrpcFile.Last_commit != nil {
+
commitWhen, _ := time.Parse(time.RFC3339, xrpcFile.Last_commit.When)
+
file.LastCommit = &types.LastCommitInfo{
+
Hash: plumbing.NewHash(xrpcFile.Last_commit.Hash),
+
Message: xrpcFile.Last_commit.Message,
+
result := types.RepoTreeResponse{
+
if xrpcResp.Parent != nil {
+
result.Parent = *xrpcResp.Parent
+
if xrpcResp.Dotdot != nil {
+
result.DotDot = *xrpcResp.Dotdot
// redirects tree paths trying to access a blob; in this case the result.Files is unpopulated,
···
+
if !rp.config.Core.Dev {
+
host := fmt.Sprintf("%s://%s", scheme, f.Knot)
+
xrpcc := &indigoxrpc.Client{
+
repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name)
+
xrpcBytes, err := tangled.RepoTags(r.Context(), xrpcc, "", 0, repo)
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+
log.Println("failed to call XRPC repo.tags", xrpcerr)
+
var result types.RepoTagsResponse
+
if err := json.Unmarshal(xrpcBytes, &result); err != nil {
+
log.Println("failed to decode XRPC response", err)
···
rp.pages.RepoTags(w, pages.RepoTagsParams{
RepoInfo: f.RepoInfo(user),
+
RepoTagsResponse: result,
ArtifactMap: artifactMap,
DanglingArtifacts: danglingArtifacts,
···
+
if !rp.config.Core.Dev {
+
host := fmt.Sprintf("%s://%s", scheme, f.Knot)
+
xrpcc := &indigoxrpc.Client{
+
repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name)
+
xrpcBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, repo)
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+
log.Println("failed to call XRPC repo.branches", xrpcerr)
+
var result types.RepoBranchesResponse
+
if err := json.Unmarshal(xrpcBytes, &result); err != nil {
+
log.Println("failed to decode XRPC response", err)
···
rp.pages.RepoBranches(w, pages.RepoBranchesParams{
RepoInfo: f.RepoInfo(user),
+
RepoBranchesResponse: result,
···
ref := chi.URLParam(r, "ref")
filePath := chi.URLParam(r, "*")
+
host := fmt.Sprintf("%s://%s", scheme, f.Knot)
+
xrpcc := &indigoxrpc.Client{
+
repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Repo.Name)
+
resp, err := tangled.RepoBlob(r.Context(), xrpcc, filePath, false, ref, repo)
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+
log.Println("failed to call XRPC repo.blob", xrpcerr)
+
// Use XRPC response directly instead of converting to internal types
var breadcrumbs [][]string
breadcrumbs = append(breadcrumbs, []string{f.Name, fmt.Sprintf("/%s/tree/%s", f.OwnerSlashRepo(), ref)})
···
+
if markup.GetFormat(resp.Path) == markup.FormatMarkdown {
showRendered = r.URL.Query().Get("code") != "true"
···
+
if resp.IsBinary != nil && *resp.IsBinary {
+
ext := strings.ToLower(filepath.Ext(resp.Path))
case ".jpg", ".jpeg", ".png", ".gif", ".svg", ".webp":
···
+
// fetch the raw binary content using sh.tangled.repo.blob xrpc
+
repoName := path.Join("%s/%s", f.OwnerDid(), f.Name)
+
blobURL := fmt.Sprintf("%s://%s/xrpc/sh.tangled.repo.blob?repo=%s&ref=%s&path=%s&raw=true",
+
scheme, f.Knot, url.QueryEscape(repoName), url.QueryEscape(ref), url.QueryEscape(filePath))
contentSrc = markup.GenerateCamoURL(rp.config.Camo.Host, rp.config.Camo.SharedSecret, blobURL)
+
if resp.IsBinary == nil || !*resp.IsBinary {
+
lines = strings.Count(resp.Content, "\n") + 1
+
sizeHint = uint64(*resp.Size)
+
sizeHint = uint64(len(resp.Content))
user := rp.oauth.GetUser(r)
+
// Determine if content is binary (dereference pointer)
+
if resp.IsBinary != nil {
+
isBinary = *resp.IsBinary
rp.pages.RepoBlob(w, pages.RepoBlobParams{
+
RepoInfo: f.RepoInfo(user),
+
BreadCrumbs: breadcrumbs,
+
ShowRendered: showRendered,
+
RenderToggle: renderToggle,
+
Unsupported: unsupported,
+
ContentSrc: contentSrc,
+
Contents: resp.Content,
···
ref := chi.URLParam(r, "ref")
filePath := chi.URLParam(r, "*")
+
repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Repo.Name)
+
blobURL := fmt.Sprintf("%s://%s/xrpc/sh.tangled.repo.blob?repo=%s&ref=%s&path=%s&raw=true",
+
scheme, f.Knot, url.QueryEscape(repo), url.QueryEscape(ref), url.QueryEscape(filePath))
req, err := http.NewRequest("GET", blobURL, nil)
···
if strings.HasPrefix(contentType, "text/") || isTextualMimeType(contentType) {
+
// serve all textual content as text/plain
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
} else if strings.HasPrefix(contentType, "image/") || strings.HasPrefix(contentType, "video/") {
+
// serve images and videos with their original content type
w.Header().Set("Content-Type", contentType)
w.WriteHeader(http.StatusUnsupportedMediaType)
w.Write([]byte("unsupported content type"))
···
+
return slices.Contains(textualTypes, mimeType)
// modify the spindle configured for this repo
···
f, err := rp.repoResolver.Resolve(r)
user := rp.oauth.GetUser(r)
+
if !rp.config.Core.Dev {
+
host := fmt.Sprintf("%s://%s", scheme, f.Knot)
+
xrpcc := &indigoxrpc.Client{
+
repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name)
+
xrpcBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, repo)
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+
log.Println("failed to call XRPC repo.branches", xrpcerr)
+
var result types.RepoBranchesResponse
+
if err := json.Unmarshal(xrpcBytes, &result); err != nil {
+
log.Println("failed to decode XRPC response", err)
···
+
if !rp.config.Core.Dev {
+
host := fmt.Sprintf("%s://%s", scheme, f.Knot)
+
xrpcc := &indigoxrpc.Client{
+
repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name)
+
branchBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, repo)
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+
log.Println("failed to call XRPC repo.branches", xrpcerr)
+
rp.pages.Notice(w, "compare-error", "Failed to produce comparison. Try again later.")
+
var branchResult types.RepoBranchesResponse
+
if err := json.Unmarshal(branchBytes, &branchResult); err != nil {
+
log.Println("failed to decode XRPC branches response", err)
rp.pages.Notice(w, "compare-error", "Failed to produce comparison. Try again later.")
+
branches := branchResult.Branches
···
+
tagBytes, err := tangled.RepoTags(r.Context(), xrpcc, "", 0, repo)
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+
log.Println("failed to call XRPC repo.tags", xrpcerr)
rp.pages.Notice(w, "compare-error", "Failed to produce comparison. Try again later.")
+
var tags types.RepoTagsResponse
+
if err := json.Unmarshal(tagBytes, &tags); err != nil {
+
log.Println("failed to decode XRPC tags response", err)
+
rp.pages.Notice(w, "compare-error", "Failed to produce comparison. Try again later.")
···
+
if !rp.config.Core.Dev {
+
host := fmt.Sprintf("%s://%s", scheme, f.Knot)
+
xrpcc := &indigoxrpc.Client{
+
repo := fmt.Sprintf("%s/%s", f.OwnerDid(), f.Name)
+
branchBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, repo)
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+
log.Println("failed to call XRPC repo.branches", xrpcerr)
+
rp.pages.Notice(w, "compare-error", "Failed to produce comparison. Try again later.")
+
var branches types.RepoBranchesResponse
+
if err := json.Unmarshal(branchBytes, &branches); err != nil {
+
log.Println("failed to decode XRPC branches response", err)
+
rp.pages.Notice(w, "compare-error", "Failed to produce comparison. Try again later.")
+
tagBytes, err := tangled.RepoTags(r.Context(), xrpcc, "", 0, repo)
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+
log.Println("failed to call XRPC repo.tags", xrpcerr)
rp.pages.Notice(w, "compare-error", "Failed to produce comparison. Try again later.")
+
var tags types.RepoTagsResponse
+
if err := json.Unmarshal(tagBytes, &tags); err != nil {
+
log.Println("failed to decode XRPC tags response", err)
+
rp.pages.Notice(w, "compare-error", "Failed to produce comparison. Try again later.")
+
compareBytes, err := tangled.RepoCompare(r.Context(), xrpcc, repo, base, head)
+
if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil {
+
log.Println("failed to call XRPC repo.compare", xrpcerr)
rp.pages.Notice(w, "compare-error", "Failed to produce comparison. Try again later.")
+
var formatPatch types.RepoFormatPatchResponse
+
if err := json.Unmarshal(compareBytes, &formatPatch); err != nil {
+
log.Println("failed to decode XRPC compare response", err)
rp.pages.Notice(w, "compare-error", "Failed to produce comparison. Try again later.")
diff := patchutil.AsNiceDiff(formatPatch.Patch, base)
repoinfo := f.RepoInfo(user)