Compare commits
9 Commits
dependabot
...
v0.30.0
Author | SHA1 | Date | |
---|---|---|---|
30906da803 | |||
665db0b8c5 | |||
558137e2ee | |||
4708c19eb1 | |||
0e12778ea3
|
|||
fe2fc171ce | |||
061d7f8e07 | |||
cd5eaeefbf | |||
a0e4e5be88 |
10
CHANGELOG.md
10
CHANGELOG.md
@ -5,12 +5,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
|
||||
## [0.30.0] 2023-01-16
|
||||
|
||||
### New Features
|
||||
|
||||
* Allow customization of the badge label ([#546])
|
||||
|
||||
### Dependency Updates
|
||||
|
||||
* Updated [`tracing-actix-web`](https://github.com/LukeMathWalker/tracing-actix-web) from 0.7.1 to 0.7.2 ([#542])
|
||||
* Updated [`git2`](https://github.com/rust-lang/git2-rs) from 0.15.0 to 0.16.0 ([#544])
|
||||
|
||||
|
||||
[#542]: https://github.com/vbrandl/hoc/pull/542
|
||||
[#544]: https://github.com/vbrandl/hoc/pull/544
|
||||
[#546]: https://github.com/vbrandl/hoc/pull/546
|
||||
|
||||
## [0.29.0] 2023-01-07
|
||||
|
||||
|
52
Cargo.lock
generated
52
Cargo.lock
generated
@ -45,7 +45,7 @@ dependencies = [
|
||||
"actix-rt",
|
||||
"actix-service",
|
||||
"actix-utils",
|
||||
"ahash",
|
||||
"ahash 0.7.6",
|
||||
"base64 0.13.0",
|
||||
"bitflags",
|
||||
"brotli",
|
||||
@ -178,7 +178,7 @@ dependencies = [
|
||||
"actix-service",
|
||||
"actix-utils",
|
||||
"actix-web-codegen",
|
||||
"ahash",
|
||||
"ahash 0.7.6",
|
||||
"bytes",
|
||||
"bytestring",
|
||||
"cfg-if",
|
||||
@ -233,6 +233,18 @@ dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf6ccdb167abbf410dcb915cabd428929d7f6a04980b54a11f26a39f1c7f7107"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"getrandom",
|
||||
"once_cell",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.18"
|
||||
@ -292,7 +304,7 @@ dependencies = [
|
||||
"actix-service",
|
||||
"actix-tls",
|
||||
"actix-utils",
|
||||
"ahash",
|
||||
"ahash 0.7.6",
|
||||
"base64 0.13.0",
|
||||
"bytes",
|
||||
"cfg-if",
|
||||
@ -815,6 +827,19 @@ name = "git2"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2994bee4a3a6a51eb90c218523be382fd7ea09b16380b9312e9dbe955ff7c7d1"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
"libgit2-sys",
|
||||
"log",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "git2"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be36bc9e0546df253c0cc41fd0af34f5e92845ad8509462ec76672fac6997f5b"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
@ -856,7 +881,7 @@ version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"ahash 0.7.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -870,7 +895,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hoc"
|
||||
version = "0.29.0"
|
||||
version = "0.30.0"
|
||||
dependencies = [
|
||||
"actix-rt",
|
||||
"actix-web",
|
||||
@ -880,7 +905,7 @@ dependencies = [
|
||||
"config",
|
||||
"dotenvy",
|
||||
"futures",
|
||||
"git2",
|
||||
"git2 0.16.0",
|
||||
"lazy_static",
|
||||
"mime",
|
||||
"number_prefix",
|
||||
@ -1072,9 +1097,9 @@ checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
|
||||
|
||||
[[package]]
|
||||
name = "libgit2-sys"
|
||||
version = "0.14.0+1.5.0"
|
||||
version = "0.14.1+1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47a00859c70c8a4f7218e6d1cc32875c4b55f6799445b842b0d8ed5e4c3d959b"
|
||||
checksum = "4a07fb2692bc3593bda59de45a502bb3071659f2c515e28c71e728306b038e17"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
@ -1275,9 +1300,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.13.0"
|
||||
version = "1.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
|
||||
checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
@ -2034,10 +2059,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tracing-bunyan-formatter"
|
||||
version = "0.3.4"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2445962f94a813b2aaea29ceeccb6dce9fd3aa5b1cb45595cde755b00d021ad"
|
||||
checksum = "78fa7c4b548e5c79a0300396f36f175da001e9933dfb5960b326db25fddbaee7"
|
||||
dependencies = [
|
||||
"ahash 0.8.2",
|
||||
"gethostname",
|
||||
"log",
|
||||
"serde",
|
||||
@ -2186,7 +2212,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"enum-iterator",
|
||||
"getset",
|
||||
"git2",
|
||||
"git2 0.15.0",
|
||||
"rustversion",
|
||||
"thiserror",
|
||||
"time",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "hoc"
|
||||
version = "0.29.0"
|
||||
version = "0.30.0"
|
||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
@ -20,7 +20,7 @@ bytes = "1.3.0"
|
||||
config = { version = "0.13.3", features = ["toml"] }
|
||||
dotenvy = "0.15.6"
|
||||
futures = "0.3.25"
|
||||
git2 = "0.15.0"
|
||||
git2 = "0.16.0"
|
||||
lazy_static = "1.4.0"
|
||||
mime = "0.3"
|
||||
number_prefix = "0.4.0"
|
||||
@ -31,7 +31,7 @@ serde_derive = "1.0.137"
|
||||
serde_json = "1.0.91"
|
||||
tracing = "0.1.37"
|
||||
tracing-actix-web = "0.7.2"
|
||||
tracing-bunyan-formatter = "0.3.4"
|
||||
tracing-bunyan-formatter = "0.3.6"
|
||||
tracing-futures = "0.2.5"
|
||||
tracing-log = "0.1.3"
|
||||
tracing-subscriber = { version = "0.3.16", features = ["registry", "env-filter"] }
|
||||
|
25
src/lib.rs
25
src/lib.rs
@ -83,8 +83,14 @@ struct JsonResponse<'a> {
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct BranchQuery {
|
||||
struct BadgeQuery {
|
||||
branch: Option<String>,
|
||||
#[serde(default = "default_label")]
|
||||
label: String,
|
||||
}
|
||||
|
||||
fn default_label() -> String {
|
||||
"Hits-of-Code".to_string()
|
||||
}
|
||||
|
||||
fn pull(path: impl AsRef<Path>) -> Result<()> {
|
||||
@ -298,7 +304,7 @@ pub(crate) async fn json_hoc<T: Service>(
|
||||
state: web::Data<State>,
|
||||
repo_count: web::Data<AtomicUsize>,
|
||||
data: web::Path<(String, String)>,
|
||||
branch: web::Query<BranchQuery>,
|
||||
branch: web::Query<BadgeQuery>,
|
||||
) -> Result<HttpResponse> {
|
||||
let branch = branch.branch.as_deref().unwrap_or("master");
|
||||
let rc_clone = repo_count.clone();
|
||||
@ -334,14 +340,15 @@ pub(crate) async fn calculate_hoc<T: Service>(
|
||||
state: web::Data<State>,
|
||||
repo_count: web::Data<AtomicUsize>,
|
||||
data: web::Path<(String, String)>,
|
||||
branch: web::Query<BranchQuery>,
|
||||
query: web::Query<BadgeQuery>,
|
||||
) -> HttpResponse {
|
||||
let rc_clone = repo_count.clone();
|
||||
let label = query.label.clone();
|
||||
let mapper = move |r| match r {
|
||||
HocResult::NotFound => p404(rc_clone),
|
||||
HocResult::Hoc { hoc_pretty, .. } => {
|
||||
let badge_opt = BadgeOptions {
|
||||
subject: "Hits-of-Code".to_string(),
|
||||
subject: label,
|
||||
color: "#007ec6".to_string(),
|
||||
status: hoc_pretty,
|
||||
};
|
||||
@ -352,10 +359,10 @@ pub(crate) async fn calculate_hoc<T: Service>(
|
||||
Ok(no_cache_response(body))
|
||||
}
|
||||
};
|
||||
let branch = branch.branch.as_deref().unwrap_or("master");
|
||||
let branch = query.branch.as_deref().unwrap_or("master");
|
||||
let error_badge = |_| {
|
||||
let error_badge = Badge::new(BadgeOptions {
|
||||
subject: "Hits-of-Code".to_string(),
|
||||
subject: query.label.clone(),
|
||||
color: "#ff0000".to_string(),
|
||||
status: "error".to_string(),
|
||||
})
|
||||
@ -372,9 +379,10 @@ async fn overview<T: Service>(
|
||||
state: web::Data<State>,
|
||||
repo_count: web::Data<AtomicUsize>,
|
||||
data: web::Path<(String, String)>,
|
||||
branch: web::Query<BranchQuery>,
|
||||
query: web::Query<BadgeQuery>,
|
||||
) -> Result<HttpResponse> {
|
||||
let branch = branch.branch.as_deref().unwrap_or("master");
|
||||
let branch = query.branch.as_deref().unwrap_or("master");
|
||||
let label = query.label.clone();
|
||||
let base_url = state.settings.base_url.clone();
|
||||
let rc_clone = repo_count.clone();
|
||||
let mapper = move |r| match r {
|
||||
@ -405,6 +413,7 @@ async fn overview<T: Service>(
|
||||
VERSION_INFO,
|
||||
rc_clone.load(Ordering::Relaxed),
|
||||
repo_info,
|
||||
label,
|
||||
)?;
|
||||
|
||||
Ok(HttpResponse::Ok().content_type("text/html").body(buf))
|
||||
|
@ -51,6 +51,10 @@ in your repository or you want a badge for another branch of your repository, ju
|
||||
<code>?branch=<branch-name></code> to the URL.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The badge label can be customized using the <code>label=<some-label></code> query parameter. It defaults to <code>Hits-of-Code</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You can also request the HoC as JSON by appending <code>/json</code> to the request path. This will return a JSON object
|
||||
with three fields: <code>count</code> (the HoC value), <code>commits</code> (the number of commits) and
|
||||
|
@ -2,7 +2,7 @@
|
||||
@use crate::statics::VersionInfo;
|
||||
@use crate::template::RepoInfo;
|
||||
|
||||
@(version_info: VersionInfo, repo_count: usize, repo_info: RepoInfo)
|
||||
@(version_info: VersionInfo, repo_count: usize, repo_info: RepoInfo, label: String)
|
||||
|
||||
@:base("Hits-of-Code Badges", "Overview", {
|
||||
|
||||
@ -19,7 +19,7 @@ To include the badge in your readme, use the following markdown:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
[](@repo_info.base_url/@repo_info.path/view?branch=@repo_info.branch)
|
||||
[](@repo_info.base_url/@repo_info.path/view?branch=@repo_info.branch&label=@label)
|
||||
</pre>
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user