Monorepo for Tangled tangled.org

appview: update state, ingester, middleware, and resolver for repo DID #1140

open opened by oyster.cafe targeting master from oyster.cafe/tangled-core: master
Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:3fwecdnvtcscjnrx2p4n7alz/sh.tangled.repo.pull/3mgprvt2eon22
+41 -34
Interdiff #11 #12
appview/ingester.go

This file has not been changed.

appview/issues/issues.go

This patch was likely rebased, as context lines do not match.

appview/middleware/middleware.go

This file has not been changed.

appview/models/issue.go

This file has not been changed.

appview/pulls/pulls.go

This patch was likely rebased, as context lines do not match.

+3 -3
appview/repo/archive.go
··· 25 25 scheme = "https" 26 26 } 27 27 host := fmt.Sprintf("%s://%s", scheme, f.Knot) 28 - didSlashRepo := f.RepoIdentifier() 28 + didSlashRepo := f.DidSlashRepo() 29 29 30 30 // build the xrpc url 31 31 u, err := url.Parse(host) ··· 60 60 if link := resp.Header.Get("Link"); link != "" { 61 61 if resolvedRef, err := extractImmutableLink(link); err == nil { 62 62 newLink := fmt.Sprintf("<%s/%s/archive/%s.tar.gz>; rel=\"immutable\"", 63 - rp.config.Core.BaseUrl(), f.DidSlashRepo(), resolvedRef) 63 + rp.config.Core.BaseUrl(), f.RepoIdentifier(), resolvedRef) 64 64 w.Header().Set("Link", newLink) 65 65 } 66 66 } ··· 70 70 if link := resp.Header.Get("Link"); link != "" { 71 71 if resolvedRef, err := extractImmutableLink(link); err == nil { 72 72 newLink := fmt.Sprintf("<%s/%s/archive/%s.tar.gz>; rel=\"immutable\"", 73 - rp.config.Core.BaseUrl(), f.RepoIdentifier(), resolvedRef) 73 + rp.config.Core.BaseUrl(), f.DidSlashRepo(), resolvedRef) 74 74 w.Header().Set("Link", newLink) 75 75 } 76 76 }
+10 -9
appview/repo/artifact.go
··· 316 316 Host: host, 317 317 } 318 318 319 - xrpcBytes, err := tangled.RepoTags(ctx, xrpcc, "", 0, f.RepoIdentifier()) 319 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 320 + xrpcBytes, err := tangled.RepoTags(ctx, xrpcc, "", 0, repo) 320 321 if err != nil { 321 322 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 322 323 l.Error("failed to call XRPC repo.tags", "err", xrpcerr) ··· 344 345 return tag, nil 345 346 } 346 347 347 - 348 - 349 - 350 - 351 - 352 - return tag, nil 353 - } 354 - 355 348 func repoArtifactRecord(f *models.Repo, blob *lexutil.LexBlob, createdAt time.Time, name string, tag []byte) *tangled.RepoArtifact { 356 349 rec := &tangled.RepoArtifact{ 357 350 Artifact: blob, ··· 366 359 } 367 360 return rec 368 361 } 362 + 363 + 364 + 365 + 366 + 367 + 368 + return tag, nil 369 + }
appview/repo/blob.go

This file has not been changed.

+2 -1
appview/repo/branches.go
··· 29 29 xrpcc := &indigoxrpc.Client{ 30 30 Host: host, 31 31 } 32 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 33 + xrpcBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, repo) 32 - xrpcBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, f.RepoIdentifier()) 33 34 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 34 35 l.Error("failed to call XRPC repo.branches", "err", xrpcerr) 35 36 rp.pages.Error503(w)
appview/repo/compare.go

This patch was likely rebased, as context lines do not match.

+8 -7
appview/repo/index.go
··· 182 182 183 183 if err != nil || langs == nil { 184 184 // non-fatal, fetch langs from ks via XRPC 185 - ls, err := tangled.RepoLanguages(ctx, xrpcc, currentRef, repo.RepoIdentifier()) 185 + didSlashRepo := fmt.Sprintf("%s/%s", repo.Did, repo.Name) 186 + ls, err := tangled.RepoLanguages(ctx, xrpcc, currentRef, didSlashRepo) 186 187 if err != nil { 187 188 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 188 189 l.Error("failed to call XRPC repo.languages", "err", xrpcerr) ··· 238 239 func (rp *Repo) buildIndexResponse(ctx context.Context, repo *models.Repo, ref string) (*types.RepoIndexResponse, error) { 239 240 xrpcc := &indigoxrpc.Client{Host: rp.config.KnotMirror.Url} 240 241 241 - // first get branches to determine the ref if not specified 242 242 branchesBytes, err := tangled.GitTempListBranches(ctx, xrpcc, "", 0, repo.RepoAt().String()) 243 243 if err != nil { 244 244 return nil, fmt.Errorf("calling knotmirror git.listBranches: %w", err) ··· 258 258 259 259 // buildIndexResponse creates a RepoIndexResponse by combining multiple xrpc calls in parallel 260 260 func (rp *Repo) buildIndexResponse(ctx context.Context, xrpcc *indigoxrpc.Client, repo *models.Repo, ref string) (*types.RepoIndexResponse, error) { 261 - repoId := repo.RepoIdentifier() 261 + didSlashRepo := fmt.Sprintf("%s/%s", repo.Did, repo.Name) 262 262 263 - branchesBytes, err := tangled.RepoBranches(ctx, xrpcc, "", 0, repoId) 263 + // first get branches to determine the ref if not specified 264 + branchesBytes, err := tangled.RepoBranches(ctx, xrpcc, "", 0, didSlashRepo) 264 265 if err != nil { 265 266 return nil, fmt.Errorf("failed to call repoBranches: %w", err) 266 267 } ··· 302 303 303 304 // tags 304 305 wg.Go(func() { 305 - tagsBytes, err := tangled.RepoTags(ctx, xrpcc, "", 0, repoId) 306 + tagsBytes, err := tangled.RepoTags(ctx, xrpcc, "", 0, didSlashRepo) 306 307 if err != nil { 307 308 errs = errors.Join(errs, fmt.Errorf("failed to call repoTags: %w", err)) 308 309 return ··· 315 316 316 317 // tree/files 317 318 wg.Go(func() { 318 - resp, err := tangled.RepoTree(ctx, xrpcc, "", ref, repoId) 319 + resp, err := tangled.RepoTree(ctx, xrpcc, "", ref, didSlashRepo) 319 320 if err != nil { 320 321 errs = errors.Join(errs, fmt.Errorf("failed to call repoTree: %w", err)) 321 322 return ··· 325 326 326 327 // commits 327 328 wg.Go(func() { 328 - logBytes, err := tangled.RepoLog(ctx, xrpcc, "", 50, "", ref, repoId) 329 + logBytes, err := tangled.RepoLog(ctx, xrpcc, "", 50, "", ref, didSlashRepo) 329 330 if err != nil { 330 331 errs = errors.Join(errs, fmt.Errorf("failed to call repoLog: %w", err)) 331 332 return
+7 -7
appview/repo/log.go
··· 57 57 cursor = strconv.Itoa(offset) 58 58 } 59 59 60 - xrpcBytes, err := tangled.RepoLog(r.Context(), xrpcc, cursor, limit, "", ref, f.RepoIdentifier()) 60 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 61 + xrpcBytes, err := tangled.RepoLog(r.Context(), xrpcc, cursor, limit, "", ref, repo) 61 62 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 62 63 l.Error("failed to call XRPC repo.log", "err", xrpcerr) 63 64 rp.pages.Error503(w) ··· 71 72 return 72 73 } 73 74 74 - repoId := f.RepoIdentifier() 75 - tagBytes, err := tangled.RepoTags(r.Context(), xrpcc, "", 0, repoId) 75 + tagBytes, err := tangled.RepoTags(r.Context(), xrpcc, "", 0, repo) 76 76 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 77 77 l.Error("failed to call XRPC repo.tags", "err", xrpcerr) 78 78 rp.pages.Error503(w) ··· 93 93 } 94 94 } 95 95 96 - branchBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, repoId) 96 + branchBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, repo) 97 97 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 98 98 l.Error("failed to call XRPC repo.branches", "err", xrpcerr) 99 99 rp.pages.Error503(w) ··· 164 164 Host: host, 165 165 } 166 166 167 - repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 168 - xrpcBytes, err := tangled.RepoDiff(r.Context(), xrpcc, ref, repo) 167 + xrpcBytes, err := tangled.RepoDiff(r.Context(), xrpcc, ref, f.RepoIdentifier()) 169 168 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 170 169 l.Error("failed to call XRPC repo.diff", "err", xrpcerr) 171 170 rp.pages.Error503(w) 172 171 Host: host, 173 172 } 174 173 175 - xrpcBytes, err := tangled.RepoDiff(r.Context(), xrpcc, ref, f.RepoIdentifier()) 174 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 175 + xrpcBytes, err := tangled.RepoDiff(r.Context(), xrpcc, ref, repo) 176 176 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 177 177 l.Error("failed to call XRPC repo.diff", "err", xrpcerr) 178 178 rp.pages.Error503(w)
appview/repo/repo.go

This patch was likely rebased, as context lines do not match.

+4 -3
appview/repo/settings.go
··· 395 395 Host: host, 396 396 } 397 397 398 - xrpcBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, f.RepoIdentifier()) 398 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 399 + xrpcBytes, err := tangled.RepoBranches(r.Context(), xrpcc, "", 0, repo) 399 400 var result types.RepoBranchesResponse 400 401 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 401 402 l.Error("failed to call XRPC repo.branches", "err", xrpcerr) ··· 458 459 user := rp.oauth.GetMultiAccountUser(r) 459 460 460 461 collaborators, err := func(repo *models.Repo) ([]pages.Collaborator, error) { 461 - repoCollaborators, err := rp.enforcer.E.GetImplicitUsersForResourceByDomain(repo.DidSlashRepo(), repo.Knot) 462 + repoCollaborators, err := rp.enforcer.E.GetImplicitUsersForResourceByDomain(repo.RepoIdentifier(), repo.Knot) 462 463 if err != nil { 463 464 return nil, err 464 465 } ··· 466 467 user := rp.oauth.GetMultiAccountUser(r) 467 468 468 469 collaborators, err := func(repo *models.Repo) ([]pages.Collaborator, error) { 469 - repoCollaborators, err := rp.enforcer.E.GetImplicitUsersForResourceByDomain(repo.RepoIdentifier(), repo.Knot) 470 + repoCollaborators, err := rp.enforcer.E.GetImplicitUsersForResourceByDomain(repo.DidSlashRepo(), repo.Knot) 470 471 if err != nil { 471 472 return nil, err 472 473 }
+5 -3
appview/repo/tags.go
··· 35 35 xrpcc := &indigoxrpc.Client{ 36 36 Host: host, 37 37 } 38 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 39 + xrpcBytes, err := tangled.RepoTags(r.Context(), xrpcc, "", 0, repo) 38 - xrpcBytes, err := tangled.RepoTags(r.Context(), xrpcc, "", 0, f.RepoIdentifier()) 39 40 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 40 41 l.Error("failed to call XRPC repo.tags", "err", xrpcerr) 41 42 rp.pages.Error503(w) ··· 97 98 xrpcc := &indigoxrpc.Client{ 98 99 Host: host, 99 100 } 101 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 100 102 tag := chi.URLParam(r, "tag") 101 103 104 + xrpcBytes, err := tangled.RepoTag(r.Context(), xrpcc, repo, tag) 102 - xrpcBytes, err := tangled.RepoTag(r.Context(), xrpcc, f.RepoIdentifier(), tag) 103 105 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 104 106 // if we don't match an existing tag, and the tag we're trying 105 107 // to match is "latest", resolve to the most recent tag 106 108 if tag == "latest" { 109 + tagsBytes, err := tangled.RepoTags(r.Context(), xrpcc, "", 1, repo) 107 - tagsBytes, err := tangled.RepoTags(r.Context(), xrpcc, "", 1, f.RepoIdentifier()) 108 110 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 109 111 l.Error("failed to call XRPC repo.tags for latest", "err", xrpcerr) 110 112 rp.pages.Error503(w)
+2 -1
appview/repo/tree.go
··· 41 41 xrpcc := &indigoxrpc.Client{ 42 42 Host: host, 43 43 } 44 + repo := fmt.Sprintf("%s/%s", f.Did, f.Name) 45 + xrpcResp, err := tangled.RepoTree(r.Context(), xrpcc, treePath, ref, repo) 44 - xrpcResp, err := tangled.RepoTree(r.Context(), xrpcc, treePath, ref, f.RepoIdentifier()) 45 46 if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 46 47 l.Error("failed to call XRPC repo.tree", "err", xrpcerr) 47 48 rp.pages.Error503(w)
appview/reporesolver/resolver.go

This file has not been changed.

appview/state/git_http.go

This file has not been changed.

appview/state/knotstream.go

This file has not been changed.

appview/state/router.go

This file has not been changed.

appview/state/star.go

This file has not been changed.

appview/state/state.go

This file has not been changed.

appview/validator/label.go

This file has not been changed.

History

14 rounds 2 comments
sign up or login to add to the discussion
1 commit
expand
appview: DID-based routing, state/handler/middleware updates
merge conflicts detected
expand
  • appview/db/repos.go:46
expand 0 comments
oyster.cafe submitted #12
1 commit
expand
appview: DID-based routing, state/handler/middleware updates
expand 0 comments
1 commit
expand
appview: DID-based routing, state/handler/middleware updates
expand 2 comments

appview/state/state.go:631 won't this eventually redirect to /{owner}/{reponame}?

wdym by eventually? I was thinking to keep this in, so that we don't simply error out if someone does decide to be clever and link to their git repo by repoDID, we should render the page anyway to reward them for being clever instead of punishing heh

1 commit
expand
appview: DID-based routing, state/handler/middleware updates
expand 0 comments
1 commit
expand
appview: DID-based routing, state/handler/middleware updates
expand 0 comments
1 commit
expand
appview: update state, ingester, middleware, and resolver for repo DID
expand 0 comments
1 commit
expand
appview: update state, ingester, middleware, and resolver for repo DID
expand 0 comments
1 commit
expand
appview: update state, ingester, middleware, and resolver for repo DID
expand 0 comments
1 commit
expand
appview: update state, ingester, middleware, and resolver for repo DID
expand 0 comments
1 commit
expand
appview: update state, ingester, middleware, and resolver for repo DID
expand 0 comments
1 commit
expand
appview: update state, ingester, middleware, and resolver for repo DID
expand 0 comments
1 commit
expand
appview: update state, ingester, middleware, and resolver for repo DID
expand 0 comments
1 commit
expand
appview: update state, ingester, middleware, and resolver for repo DID
expand 0 comments
1 commit
expand
appview: update state, ingester, middleware, and resolver for repo DID
expand 0 comments