Codeberg support (#134)

This commit is contained in:
Atk 2022-01-19 00:51:33 +00:00 committed by GitHub
parent e8fbb00ada
commit 8bdee6b770
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 4 deletions

View file

@ -13,7 +13,7 @@ We currently support projects and crates hosted on crates.io, Github, Gitlab, Bi
To analyze the state of your dependencies you can use the following URLs: To analyze the state of your dependencies you can use the following URLs:
- for projects on crates.io: `https://deps.rs/crate/<NAME>` - for projects on crates.io: `https://deps.rs/crate/<NAME>`
- for projects on Github, Gitlab, Bitbucket, or SourceHut: `https://deps.rs/repo/<HOSTER>/<USER>/<REPO>` (where `<HOSTER>` is either `github`, `gitlab`, `bitbucket`, or `sourcehut`) - for projects on Github, Gitlab, Bitbucket, SourceHut, or Codeberg: `https://deps.rs/repo/<HOSTER>/<USER>/<REPO>` (where `<HOSTER>` is either `github`, `gitlab`, `bitbucket`, `sourcehut`, or `codeberg`)
On the analysis page, you will also find the markdown code to include a fancy badge in your project README so visitors (and you) can see at a glance if your dependencies are still up to date! On the analysis page, you will also find the markdown code to include a fancy badge in your project README so visitors (and you) can see at a glance if your dependencies are still up to date!

View file

@ -55,6 +55,7 @@ pub enum RepoSite {
Gitlab, Gitlab,
Bitbucket, Bitbucket,
Sourcehut, Sourcehut,
Codeberg,
} }
impl RepoSite { impl RepoSite {
@ -64,6 +65,7 @@ impl RepoSite {
RepoSite::Gitlab => "https://gitlab.com", RepoSite::Gitlab => "https://gitlab.com",
RepoSite::Bitbucket => "https://bitbucket.org", RepoSite::Bitbucket => "https://bitbucket.org",
RepoSite::Sourcehut => "https://git.sr.ht", RepoSite::Sourcehut => "https://git.sr.ht",
RepoSite::Codeberg => "https://codeberg.org",
} }
} }
@ -73,6 +75,7 @@ impl RepoSite {
RepoSite::Gitlab => "https://gitlab.com", RepoSite::Gitlab => "https://gitlab.com",
RepoSite::Bitbucket => "https://bitbucket.org", RepoSite::Bitbucket => "https://bitbucket.org",
RepoSite::Sourcehut => "https://git.sr.ht", RepoSite::Sourcehut => "https://git.sr.ht",
RepoSite::Codeberg => "https://codeberg.org",
} }
} }
@ -81,6 +84,7 @@ impl RepoSite {
RepoSite::Github => "HEAD", RepoSite::Github => "HEAD",
RepoSite::Gitlab | RepoSite::Bitbucket => "raw/HEAD", RepoSite::Gitlab | RepoSite::Bitbucket => "raw/HEAD",
RepoSite::Sourcehut => "blob/HEAD", RepoSite::Sourcehut => "blob/HEAD",
RepoSite::Codeberg => "raw",
} }
} }
} }
@ -94,6 +98,7 @@ impl FromStr for RepoSite {
"gitlab" => Ok(RepoSite::Gitlab), "gitlab" => Ok(RepoSite::Gitlab),
"bitbucket" => Ok(RepoSite::Bitbucket), "bitbucket" => Ok(RepoSite::Bitbucket),
"sourcehut" => Ok(RepoSite::Sourcehut), "sourcehut" => Ok(RepoSite::Sourcehut),
"codeberg" => Ok(RepoSite::Codeberg),
_ => Err(anyhow!("unknown repo site identifier")), _ => Err(anyhow!("unknown repo site identifier")),
} }
} }
@ -106,6 +111,7 @@ impl AsRef<str> for RepoSite {
RepoSite::Gitlab => "gitlab", RepoSite::Gitlab => "gitlab",
RepoSite::Bitbucket => "bitbucket", RepoSite::Bitbucket => "bitbucket",
RepoSite::Sourcehut => "sourcehut", RepoSite::Sourcehut => "sourcehut",
RepoSite::Codeberg => "codeberg",
} }
} }
} }
@ -201,5 +207,13 @@ mod tests {
); );
assert_eq!(out.to_string(), exp); assert_eq!(out.to_string(), exp);
} }
for (input, expected) in &paths {
let repo = RepoPath::from_parts("codeberg", "deps-rs", "deps.rs").unwrap();
let out = repo.to_usercontent_file_url(RelativePath::new(input));
let exp = format!("https://codeberg.org/deps-rs/deps.rs/raw/{}", expected);
assert_eq!(out.to_string(), exp);
}
} }
} }

View file

@ -126,9 +126,9 @@ fn get_site_icon(site: &RepoSite) -> (FaType, &'static str) {
RepoSite::Github => (FaType::Brands, "github"), RepoSite::Github => (FaType::Brands, "github"),
RepoSite::Gitlab => (FaType::Brands, "gitlab"), RepoSite::Gitlab => (FaType::Brands, "gitlab"),
RepoSite::Bitbucket => (FaType::Brands, "bitbucket"), RepoSite::Bitbucket => (FaType::Brands, "bitbucket"),
// FIXME: There is no brands/sourcehut icon, so just use a regular // FIXME: There is no brands/{sourcehut, codeberg} icon, so just use a
// circle which looks pretty much like sr.ht's circle. // regular circle which looks close enough.
RepoSite::Sourcehut => (FaType::Regular, "circle"), RepoSite::Sourcehut | RepoSite::Codeberg => (FaType::Regular, "circle"),
} }
} }