Skip to content

Commit 7e312bb

Browse files
mirydevnote-devstraight-shoota
authored
Add support for Codeberg as a git resolver (#656)
Co-authored-by: Devonte <[email protected]> Co-authored-by: Johannes Müller <[email protected]>
1 parent 20aaeaf commit 7e312bb

File tree

5 files changed

+43
-3
lines changed

5 files changed

+43
-3
lines changed

docs/shard.yml.adoc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ A path to the source file to compile (string).
273273
== DEPENDENCY ATTRIBUTES
274274

275275
Each dependency needs at least one attribute that defines the resolver for this
276-
dependency. Those can be _path_, _git_, _github_, _gitlab_, _bitbucket_.
276+
dependency. Those can be _path_, _git_, _github_, _gitlab_, _bitbucket_, _codeberg_.
277277

278278
*path*::
279279
A local path (string).
@@ -320,6 +320,13 @@ Extends the _git_ resolver, and acts exactly like it.
320320
+
321321
*Example:* _bitbucket: tom/library_
322322

323+
*codeberg*::
324+
Codeberg repository URL as _user/repo_ (string).
325+
+
326+
Extends the _git_ resolver, and acts exactly like it.
327+
+
328+
*Example:* _codeberg: tom/library_
329+
323330
*hg*::
324331

325332
A Mercurial repository URL (string).

docs/shard.yml.schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@
5757
"title": "Bitbucket URL",
5858
"description": "Bitbucket repository URL as user/repo"
5959
},
60+
"codeberg": {
61+
"type": "string",
62+
"title": "Codeberg URL",
63+
"description": "Codeberg repository URL as user/repo"
64+
},
6065
"git": {
6166
"type": "string",
6267
"title": "git URL",
@@ -130,6 +135,11 @@
130135
"title": "Bitbucket URL",
131136
"description": "Bitbucket repository URL as user/repo"
132137
},
138+
"codeberg": {
139+
"type": "string",
140+
"title": "Codeberg URL",
141+
"description": "Codeberg repository URL as user/repo"
142+
},
133143
"git": {
134144
"type": "string",
135145
"title": "git URL",

man/shard.yml.5

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/unit/git_resolver_spec.cr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ module Shards
3939
GitResolver.normalize_key_source("gitlab", "repo/path").should eq({"git", "https://gitlab.com/repo/path.git"})
4040
GitResolver.normalize_key_source("gitlab", "rEpo/pAth").should eq({"git", "https://gitlab.com/repo/path.git"})
4141
GitResolver.normalize_key_source("gitlab", "REPO/PATH").should eq({"git", "https://gitlab.com/repo/path.git"})
42+
GitResolver.normalize_key_source("codeberg", "REPO/PATH").should eq({"git", "https://codeberg.org/repo/path.git"})
4243

4344
# normalise full git paths
4445
GitResolver.normalize_key_source("git", "HTTPS://User:[email protected]/Repo/Path.git?Shallow=true")[1].should eq "https://User:[email protected]/repo/path.git?Shallow=true"
4546
GitResolver.normalize_key_source("git", "HTTPS://User:[email protected]/Repo/Path.Git?Shallow=true")[1].should eq "https://User:[email protected]/repo/path.git?Shallow=true"
4647
GitResolver.normalize_key_source("git", "HTTPS://User:[email protected]/Repo/Path?Shallow=true")[1].should eq "https://User:[email protected]/repo/path.git?Shallow=true"
4748
GitResolver.normalize_key_source("git", "HTTPS://User:[email protected]/Repo/Path?Shallow=true")[1].should eq "https://User:[email protected]/repo/path.git?Shallow=true"
49+
GitResolver.normalize_key_source("git", "HTTPS://User:[email protected]/Repo/Path.Git?Shallow=true")[1].should eq "https://User:[email protected]/repo/path.git?Shallow=true"
4850

4951
# don't normalise other domains
5052
GitResolver.normalize_key_source("git", "HTTPs://mygitserver.com/Repo.git").should eq({"git", "HTTPs://mygitserver.com/Repo.git"})

src/resolvers/git.cr

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,16 @@ module Shards
100100
"git"
101101
end
102102

103-
private KNOWN_PROVIDERS = {"www.github.com", "github.com", "www.bitbucket.com", "bitbucket.com", "www.gitlab.com", "gitlab.com"}
103+
private KNOWN_PROVIDERS = {
104+
"www.github.com",
105+
"github.com",
106+
"www.bitbucket.com",
107+
"bitbucket.com",
108+
"www.gitlab.com",
109+
"gitlab.com",
110+
"www.codeberg.org",
111+
"codeberg.org",
112+
}
104113

105114
def self.normalize_key_source(key : String, source : String) : {String, String}
106115
case key
@@ -120,6 +129,8 @@ module Shards
120129
end
121130
when "github", "bitbucket", "gitlab"
122131
{"git", "https://#{key}.com/#{source.downcase}.git"}
132+
when "codeberg"
133+
{"git", "https://#{key}.org/#{source.downcase}.git"}
123134
else
124135
raise "Unknown resolver #{key}"
125136
end
@@ -458,5 +469,6 @@ module Shards
458469
register_resolver "github", GitResolver
459470
register_resolver "gitlab", GitResolver
460471
register_resolver "bitbucket", GitResolver
472+
register_resolver "codeberg", GitResolver
461473
end
462474
end

0 commit comments

Comments
 (0)