Monorepo for Tangled tangled.org

knotserver: add repo DID migration on startup #1144

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/3mgprvt2exw22
+26
Interdiff #0 #1
+20
appview/middleware/middleware.go
··· 226 226 return 227 227 } 228 228 229 + if repo.RepoDid != "" && req.Context().Value("repoDidCanonical") == nil { 230 + gitPaths := []string{"/info/refs", "/git-upload-pack", "/git-receive-pack", "/git-upload-archive"} 231 + user := chi.URLParam(req, "user") 232 + repoParam := chi.URLParam(req, "repo") 233 + remaining := strings.TrimPrefix(req.URL.Path, "/"+user+"/"+repoParam) 234 + 235 + isGitPath := slices.ContainsFunc(gitPaths, func(p string) bool { 236 + return strings.HasSuffix(remaining, p) 237 + }) 238 + 239 + if !isGitPath && req.URL.Query().Get("go-get") != "1" { 240 + target := "/" + repo.RepoDid + remaining 241 + if req.URL.RawQuery != "" { 242 + target += "?" + req.URL.RawQuery 243 + } 244 + http.Redirect(w, req, target, http.StatusFound) 245 + return 246 + } 247 + } 248 + 229 249 ctx := context.WithValue(req.Context(), "repo", repo) 230 250 next.ServeHTTP(w, req.WithContext(ctx)) 231 251 })
+6
appview/pages/repoinfo/repoinfo.go
··· 20 20 } 21 21 22 22 func (r RepoInfo) FullName() string { 23 + if r.RepoDid != "" { 24 + return r.RepoDid 25 + } 23 26 return path.Join(r.owner(), r.Name) 24 27 } 25 28 ··· 32 35 } 33 36 34 37 func (r RepoInfo) FullNameWithoutAt() string { 38 + if r.RepoDid != "" { 39 + return userutil.FlattenDid(r.RepoDid) 40 + } 35 41 return path.Join(r.ownerWithoutAt(), r.Name) 36 42 } 37 43
appview/state/router.go

This file has not been changed.

eventconsumer/consumer.go

This file has not been changed.

knotserver/events.go

This file has not been changed.

knotserver/migrate.go

This file has not been changed.

knotserver/server.go

This file has not been changed.

spindle/stream.go

This file has not been changed.

History

12 rounds 1 comment
sign up or login to add to the discussion
1 commit
expand
knotserver: add repo DID migration on startup
merge conflicts detected
expand
  • go.mod:34
  • go.sum:339
expand 0 comments
1 commit
expand
knotserver: add repo DID migration on startup
expand 0 comments
1 commit
expand
knotserver: add repo DID migration on startup
expand 1 comment
1 commit
expand
knotserver: add repo DID migration on startup
expand 0 comments
1 commit
expand
knotserver: add repo DID migration on startup
expand 0 comments
1 commit
expand
knotserver: add repo DID migration on startup
expand 0 comments
1 commit
expand
knotserver: add repo DID migration on startup
expand 0 comments
1 commit
expand
knotserver: add repo DID migration on startup
expand 0 comments
1 commit
expand
knotserver: add repo DID migration on startup
expand 0 comments
1 commit
expand
knotserver: add repo DID migration on startup
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
knotserver: add repo DID migration on startup
expand 0 comments
1 commit
expand
knotserver: add repo DID migration on startup
expand 0 comments