A container registry that uses the AT Protocol for manifest storage and S3 for blob storage. atcr.io
docker container atproto go

Adds Codeberg as a source for the README.md #2

merged opened by cuducos.me targeting main from cuducos.me/at-container-registry: codeberg-source

My guess is that many ATProto users are enthusiasts of decentralization and some of them (like me o/) might have migrated some stuff to Codeberg too. This PR allows us to read README.md from Codeberg (as well as from GitHub, GitLab and Tangled that were already there!)

For example, a repo like https://codeberg.org/Codeberg/Contributing and branch wiki-notice should resolve to https://codeberg.org/Codeberg/Contributing/raw/branch/wiki-notice/README.md.

Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:3272gdrjsuikiff7qsgokgas/sh.tangled.repo.pull/3mbkh5tyofk22
+38 -7
Diff #0
+20 -7
pkg/appview/readme/source.go
··· 10 10 type Platform string 11 11 12 12 const ( 13 - PlatformGitHub Platform = "github" 14 - PlatformGitLab Platform = "gitlab" 15 - PlatformTangled Platform = "tangled" 13 + PlatformGitHub Platform = "github" 14 + PlatformGitLab Platform = "gitlab" 15 + PlatformTangled Platform = "tangled" 16 + PlatformCodeberg Platform = "codeberg" 16 17 ) 17 18 18 19 // ParseSourceURL extracts platform, user, and repo from a source repository URL. ··· 38 39 39 40 host := strings.ToLower(parsed.Host) 40 41 41 - switch { 42 - case host == "github.com": 42 + switch host { 43 + case "github.com": 43 44 // GitHub: github.com/{user}/{repo} 44 45 parts := strings.SplitN(path, "/", 3) 45 46 if len(parts) < 2 || parts[0] == "" || parts[1] == "" { ··· 47 48 } 48 49 return PlatformGitHub, parts[0], parts[1], true 49 50 50 - case host == "gitlab.com": 51 + case "gitlab.com": 51 52 // GitLab: gitlab.com/{user}/{repo} or gitlab.com/{group}/{subgroup}/{repo} 52 53 // For nested groups, user = everything except last part, repo = last part 53 54 lastSlash := strings.LastIndex(path, "/") ··· 61 62 } 62 63 return PlatformGitLab, user, repo, true 63 64 64 - case host == "tangled.org" || host == "tangled.sh": 65 + case "tangled.org", "tangled.sh": 65 66 // Tangled: tangled.org/{user}/{repo} or tangled.sh/@{user}/{repo} (legacy) 66 67 // Strip leading @ from user if present 67 68 path = strings.TrimPrefix(path, "@") ··· 71 72 } 72 73 return PlatformTangled, parts[0], parts[1], true 73 74 75 + case "codeberg.org": 76 + // Codeberg: codeberg.org/{user}/{repo} 77 + parts := strings.SplitN(path, "/", 3) 78 + if len(parts) < 2 || parts[0] == "" || parts[1] == "" { 79 + return "", "", "", false 80 + } 81 + return PlatformCodeberg, parts[0], parts[1], true 82 + 74 83 default: 75 84 return "", "", "", false 76 85 } ··· 97 106 // https://tangled.org/{user}/{repo}/raw/{branch}/README.md 98 107 return fmt.Sprintf("https://tangled.org/%s/%s/raw/%s/README.md", user, repo, branch) 99 108 109 + case PlatformCodeberg: 110 + // https://codeberg.org/{user}/{repo}/raw/branch/{branch}/README.md 111 + return fmt.Sprintf("https://codeberg.org/%s/%s/raw/branch/%s/README.md", user, repo, branch) 112 + 100 113 default: 101 114 return "" 102 115 }
+18
pkg/appview/readme/source_test.go
··· 120 120 wantOK: true, 121 121 }, 122 122 123 + // Codeberg 124 + { 125 + name: "codeberg standard", 126 + sourceURL: "https://codeberg.org/user/repo", 127 + wantPlatform: PlatformCodeberg, 128 + wantUser: "user", 129 + wantRepo: "repo", 130 + wantOK: true, 131 + }, 132 + 123 133 // Unsupported / Invalid 124 134 { 125 135 name: "unsupported platform", ··· 215 225 want: "https://tangled.org/user/repo/raw/main/README.md", 216 226 }, 217 227 228 + // Codeberg 229 + { 230 + name: "codeberg main", 231 + sourceURL: "https://codeberg.org/user/repo", 232 + branch: "main", 233 + want: "https://codeberg.org/user/repo/raw/branch/main/README.md", 234 + }, 235 + 218 236 // Unsupported 219 237 { 220 238 name: "unsupported platform",

History

1 round 1 comment
sign up or login to add to the discussion
cuducos.me submitted #0
1 commit
expand
Adds Codeberg as a source
expand 1 comment

Looks good.

Just a note, the semi-secret way to handle any url is to update your labels/annotations with io.atcr.readme= https://tangled.org/evan.jarrett.net/at-container-registry/blob/main/Dockerfile.appview#L41-42

pull request successfully merged