Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
f6d47baefd | |||
44d47b1d5f | |||
3a57fcca9d | |||
3051bdc0c7 |
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -954,7 +954,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hoc"
|
||||
version = "0.17.4"
|
||||
version = "0.18.0"
|
||||
dependencies = [
|
||||
"actix-rt",
|
||||
"actix-web",
|
||||
@ -2594,9 +2594,9 @@ checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb"
|
||||
|
||||
[[package]]
|
||||
name = "vergen"
|
||||
version = "5.1.2"
|
||||
version = "5.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0277ffac28b64e449a7a8c369ddd8591647c5a2d1fd513eebd6a153ff4c40ea4"
|
||||
checksum = "542f37b4798c879409865dde7908e746d836f77839c3a6bea5c8b4e4dcf6620b"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cfg-if 1.0.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "hoc"
|
||||
version = "0.17.4"
|
||||
version = "0.18.0"
|
||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
@ -37,7 +37,7 @@ tracing-subscriber = { version = "0.2.19", features = ["registry", "env-filter"]
|
||||
|
||||
[build-dependencies]
|
||||
ructe = "0.13.4"
|
||||
vergen = { version = "5.1.2", default-features = false, features = ["git"] }
|
||||
vergen = { version = "5.1.13", default-features = false, features = ["git"] }
|
||||
|
||||
[dev-dependencies]
|
||||
ructe = "0.13.4"
|
||||
|
@ -22,7 +22,7 @@ use crate::{
|
||||
cache::CacheState,
|
||||
config::Settings,
|
||||
error::{Error, Result},
|
||||
service::{Bitbucket, FormService, GitHub, Gitlab, Service},
|
||||
service::{Bitbucket, FormService, GitHub, Gitlab, Service, Sourcehut},
|
||||
statics::{CLIENT, CSS, FAVICON, VERSION_INFO},
|
||||
template::RepoInfo,
|
||||
};
|
||||
@ -490,6 +490,7 @@ async fn start_server(listener: TcpListener, settings: Settings) -> std::io::Res
|
||||
.service(web::resource("/github/{user}/{repo}").to(calculate_hoc::<GitHub>))
|
||||
.service(web::resource("/gitlab/{user}/{repo}").to(calculate_hoc::<Gitlab>))
|
||||
.service(web::resource("/bitbucket/{user}/{repo}").to(calculate_hoc::<Bitbucket>))
|
||||
.service(web::resource("/sourcehut/{user}/{repo}").to(calculate_hoc::<Sourcehut>))
|
||||
.service(
|
||||
web::resource("/github/{user}/{repo}/delete")
|
||||
.route(web::post().to(delete_repo_and_cache::<GitHub>)),
|
||||
@ -502,15 +503,21 @@ async fn start_server(listener: TcpListener, settings: Settings) -> std::io::Res
|
||||
web::resource("/bitbucket/{user}/{repo}/delete")
|
||||
.route(web::post().to(delete_repo_and_cache::<Bitbucket>)),
|
||||
)
|
||||
.service(
|
||||
web::resource("/sourcehut/{user}/{repo}/delete")
|
||||
.route(web::post().to(delete_repo_and_cache::<Sourcehut>)),
|
||||
)
|
||||
.service(web::resource("/github/{user}/{repo}/json").to(json_hoc::<GitHub>))
|
||||
.service(web::resource("/gitlab/{user}/{repo}/json").to(json_hoc::<Gitlab>))
|
||||
.service(web::resource("/bitbucket/{user}/{repo}/json").to(json_hoc::<Bitbucket>))
|
||||
.service(web::resource("/sourcehut/{user}/{repo}/json").to(json_hoc::<Sourcehut>))
|
||||
.service(web::resource("/view/github/{user}/{repo}").to(overview::<GitHub>))
|
||||
.service(web::resource("/view/gitlab/{user}/{repo}").to(overview::<Gitlab>))
|
||||
.service(web::resource("/view/bitbucket/{user}/{repo}").to(overview::<Bitbucket>))
|
||||
.service(web::resource("/github/{user}/{repo}/view").to(overview::<GitHub>))
|
||||
.service(web::resource("/gitlab/{user}/{repo}/view").to(overview::<Gitlab>))
|
||||
.service(web::resource("/bitbucket/{user}/{repo}/view").to(overview::<Bitbucket>))
|
||||
.service(web::resource("/sourcehut/{user}/{repo}/view").to(overview::<Sourcehut>))
|
||||
.default_service(web::resource("").route(web::get().to(async_p404)))
|
||||
})
|
||||
.workers(workers)
|
||||
|
@ -12,6 +12,8 @@ pub(crate) enum FormService {
|
||||
Gitlab,
|
||||
#[serde(rename = "bitbucket")]
|
||||
Bitbucket,
|
||||
#[serde(rename = "sourcehut")]
|
||||
Sourcehut,
|
||||
}
|
||||
|
||||
impl FormService {
|
||||
@ -20,6 +22,7 @@ impl FormService {
|
||||
FormService::GitHub => "github.com",
|
||||
FormService::Gitlab => "gitlab.com",
|
||||
FormService::Bitbucket => "bitbucket.org",
|
||||
FormService::Sourcehut => "git.sr.ht",
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +31,7 @@ impl FormService {
|
||||
FormService::GitHub => "github",
|
||||
FormService::Gitlab => "gitlab",
|
||||
FormService::Bitbucket => "bitbucket",
|
||||
FormService::Sourcehut => "sourcehut",
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -73,3 +77,17 @@ impl Service for Bitbucket {
|
||||
format!("https://{}/{}/commits/{}", Self::domain(), repo, commit_ref)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct Sourcehut;
|
||||
|
||||
impl Service for Sourcehut {
|
||||
fn domain() -> &'static str {
|
||||
"git.sr.ht"
|
||||
}
|
||||
fn url_path() -> &'static str {
|
||||
"sourcehut"
|
||||
}
|
||||
fn commit_url(repo: &str, commit_ref: &str) -> String {
|
||||
format!("https://{}/{}/commit/{}", Self::domain(), repo, commit_ref)
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ gives an overview about the amount of work put into a codebase.
|
||||
<p>
|
||||
There is a <a href="https://github.com/yegor256/hoc/">command-line tool</a> to calculate the HoC of a repository, but
|
||||
some people might want a nice badge to put in their README, that's why I implemented this API. Currently the API can be
|
||||
used for GitHub, GitLab and Bitbucket repositories. Just put the following code in your README:
|
||||
used for GitHub, GitLab, Bitbucket and Sourcehut repositories. Just put the following code in your README:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
@ -28,8 +28,8 @@ used for GitHub, GitLab and Bitbucket repositories. Just put the following code
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
where <code><service></code> is one of <code>github</code>, <code>gitlab</code> or <code>bitbucket</code>. So the
|
||||
following Markdown
|
||||
where <code><service></code> is one of <code>github</code>, <code>gitlab</code>, <code>bitbucket</code> or
|
||||
<code>sourcehut</code>. So the following Markdown
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
@ -74,6 +74,7 @@ the lines of
|
||||
<option value="github">GitHub</option>
|
||||
<option value="gitlab">Gitlab</option>
|
||||
<option value="bitbucket">Bitbucket</option>
|
||||
<option value="sourcehut">Sourcehut</option>
|
||||
</select>
|
||||
<label>/</label>
|
||||
<input name="user" id="user" type="text" placeholder="user" />
|
||||
|
Reference in New Issue
Block a user