Compare commits

...

18 Commits

Author SHA1 Message Date
00ee175e8b Update changelog
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-20 12:16:57 +01:00
c0bafa6079 chore(deps): Bump reqwest from 0.11.13 to 0.11.14
Bumps [reqwest](https://github.com/seanmonstar/reqwest) from 0.11.13 to 0.11.14.
- [Release notes](https://github.com/seanmonstar/reqwest/releases)
- [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/seanmonstar/reqwest/compare/v0.11.13...v0.11.14)

---
updated-dependencies:
- dependency-name: reqwest
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-20 04:05:02 +00:00
18fb75e13e Merge pull request #547 from vbrandl/dependabot/cargo/tokio-1.24.2
chore(deps): Bump tokio from 1.24.1 to 1.24.2
2023-01-18 12:27:39 +01:00
9a578565bd Update changelog 2023-01-18 12:19:02 +01:00
ffb7acc738 chore(deps): Bump tokio from 1.24.1 to 1.24.2
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.24.1 to 1.24.2.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/commits)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-18 04:03:28 +00:00
8b058d9c53 Merge pull request #546 from vbrandl/feature/badge-label
All checks were successful
continuous-integration/drone/push Build is passing
Allow customization of the badge label
2023-01-16 10:05:36 +01:00
30906da803 Bump version (v0.30.0)
All checks were successful
continuous-integration/drone/tag Build is passing
2023-01-16 10:02:36 +01:00
665db0b8c5 Update changelog 2023-01-16 09:59:52 +01:00
558137e2ee Allow customization of the badge label 2023-01-16 09:54:04 +01:00
4708c19eb1 Merge pull request #544 from vbrandl/dependabot/cargo/git2-0.16.0
chore(deps): Bump git2 from 0.15.0 to 0.16.0
2023-01-13 12:39:46 +01:00
0e12778ea3 Update changelog
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-13 12:29:23 +01:00
fe2fc171ce chore(deps): Bump git2 from 0.15.0 to 0.16.0
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.15.0 to 0.16.0.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/git2-curl-0.15.0...git2-curl-0.16.0)

---
updated-dependencies:
- dependency-name: git2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-13 11:28:23 +00:00
061d7f8e07 Merge pull request #543 from vbrandl/dependabot/cargo/tracing-bunyan-formatter-0.3.6
chore(deps): Bump tracing-bunyan-formatter from 0.3.4 to 0.3.6
2023-01-13 12:27:02 +01:00
cd5eaeefbf chore(deps): Bump tracing-bunyan-formatter from 0.3.4 to 0.3.6
Bumps [tracing-bunyan-formatter](https://github.com/LukeMathWalker/tracing-bunyan-formatter) from 0.3.4 to 0.3.6.
- [Release notes](https://github.com/LukeMathWalker/tracing-bunyan-formatter/releases)
- [Commits](https://github.com/LukeMathWalker/tracing-bunyan-formatter/compare/v0.3.4...v0.3.6)

---
updated-dependencies:
- dependency-name: tracing-bunyan-formatter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-13 11:15:00 +00:00
a0e4e5be88 Merge pull request #542 from vbrandl/dependabot/cargo/tracing-actix-web-0.7.2
chore(deps): Bump tracing-actix-web from 0.7.1 to 0.7.2
2023-01-13 12:09:52 +01:00
f179bd875e Update changelog
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-13 12:03:21 +01:00
7445bdd29d chore(deps): Bump tracing-actix-web from 0.7.1 to 0.7.2
Bumps [tracing-actix-web](https://github.com/LukeMathWalker/tracing-actix-web) from 0.7.1 to 0.7.2.
- [Release notes](https://github.com/LukeMathWalker/tracing-actix-web/releases)
- [Commits](https://github.com/LukeMathWalker/tracing-actix-web/compare/v0.7.1...v0.7.2)

---
updated-dependencies:
- dependency-name: tracing-actix-web
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-09 04:05:39 +00:00
44a40cb086 Merge pull request #540 from vbrandl/release/v0.29.0
All checks were successful
continuous-integration/drone/push Build is passing
Release/v0.29.0
2023-01-07 16:34:43 +01:00
6 changed files with 104 additions and 36 deletions

View File

@ -5,6 +5,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Dependency Updates
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.24.1 to 1.24.2 ([#547])
* Updated [`reqwest`](https://github.com/seanmonstar/reqwest) from 0.11.13 to 0.11.14 ([#549])
[#547]: https://github.com/vbrandl/hoc/pull/547
## [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 ## [0.29.0] 2023-01-07

72
Cargo.lock generated
View File

@ -45,7 +45,7 @@ dependencies = [
"actix-rt", "actix-rt",
"actix-service", "actix-service",
"actix-utils", "actix-utils",
"ahash", "ahash 0.7.6",
"base64 0.13.0", "base64 0.13.0",
"bitflags", "bitflags",
"brotli", "brotli",
@ -178,7 +178,7 @@ dependencies = [
"actix-service", "actix-service",
"actix-utils", "actix-utils",
"actix-web-codegen", "actix-web-codegen",
"ahash", "ahash 0.7.6",
"bytes", "bytes",
"bytestring", "bytestring",
"cfg-if", "cfg-if",
@ -233,6 +233,18 @@ dependencies = [
"version_check", "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]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "0.7.18" version = "0.7.18"
@ -292,7 +304,7 @@ dependencies = [
"actix-service", "actix-service",
"actix-tls", "actix-tls",
"actix-utils", "actix-utils",
"ahash", "ahash 0.7.6",
"base64 0.13.0", "base64 0.13.0",
"bytes", "bytes",
"cfg-if", "cfg-if",
@ -337,6 +349,12 @@ version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5" checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5"
[[package]]
name = "base64"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.3.2" version = "1.3.2"
@ -815,6 +833,19 @@ name = "git2"
version = "0.15.0" version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2994bee4a3a6a51eb90c218523be382fd7ea09b16380b9312e9dbe955ff7c7d1" 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 = [ dependencies = [
"bitflags", "bitflags",
"libc", "libc",
@ -856,7 +887,7 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3" checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3"
dependencies = [ dependencies = [
"ahash", "ahash 0.7.6",
] ]
[[package]] [[package]]
@ -870,7 +901,7 @@ dependencies = [
[[package]] [[package]]
name = "hoc" name = "hoc"
version = "0.29.0" version = "0.30.0"
dependencies = [ dependencies = [
"actix-rt", "actix-rt",
"actix-web", "actix-web",
@ -880,7 +911,7 @@ dependencies = [
"config", "config",
"dotenvy", "dotenvy",
"futures", "futures",
"git2", "git2 0.16.0",
"lazy_static", "lazy_static",
"mime", "mime",
"number_prefix", "number_prefix",
@ -1072,9 +1103,9 @@ checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
[[package]] [[package]]
name = "libgit2-sys" 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" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47a00859c70c8a4f7218e6d1cc32875c4b55f6799445b842b0d8ed5e4c3d959b" checksum = "4a07fb2692bc3593bda59de45a502bb3071659f2c515e28c71e728306b038e17"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
@ -1275,9 +1306,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.13.0" version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
[[package]] [[package]]
name = "opaque-debug" name = "opaque-debug"
@ -1601,11 +1632,11 @@ dependencies = [
[[package]] [[package]]
name = "reqwest" name = "reqwest"
version = "0.11.13" version = "0.11.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68cc60575865c7831548863cc02356512e3f1dc2f3f82cb837d7fc4cc8f3c97c" checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9"
dependencies = [ dependencies = [
"base64 0.13.0", "base64 0.21.0",
"bytes", "bytes",
"encoding_rs", "encoding_rs",
"futures-core", "futures-core",
@ -1941,9 +1972,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.24.1" version = "1.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d9f76183f91ecfb55e1d7d5602bd1d979e38a3a522fe900241cf195624d67ae" checksum = "597a12a59981d9e3c38d216785b0c37399f6e415e8d0712047620f189371b0bb"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"bytes", "bytes",
@ -2011,9 +2042,9 @@ dependencies = [
[[package]] [[package]]
name = "tracing-actix-web" name = "tracing-actix-web"
version = "0.7.1" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d16c2a0c52b267d46ea9a46012a28b3513ce166c28eaeaa875829ed2f8debd19" checksum = "4082e4d81173e0b7ad3cfb71e9eaef0dd0cbb7b139fdb56394f488a3b0760b23"
dependencies = [ dependencies = [
"actix-web", "actix-web",
"pin-project", "pin-project",
@ -2034,10 +2065,11 @@ dependencies = [
[[package]] [[package]]
name = "tracing-bunyan-formatter" name = "tracing-bunyan-formatter"
version = "0.3.4" version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2445962f94a813b2aaea29ceeccb6dce9fd3aa5b1cb45595cde755b00d021ad" checksum = "78fa7c4b548e5c79a0300396f36f175da001e9933dfb5960b326db25fddbaee7"
dependencies = [ dependencies = [
"ahash 0.8.2",
"gethostname", "gethostname",
"log", "log",
"serde", "serde",
@ -2186,7 +2218,7 @@ dependencies = [
"cfg-if", "cfg-if",
"enum-iterator", "enum-iterator",
"getset", "getset",
"git2", "git2 0.15.0",
"rustversion", "rustversion",
"thiserror", "thiserror",
"time", "time",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "hoc" name = "hoc"
version = "0.29.0" version = "0.30.0"
authors = ["Valentin Brandl <vbrandl@riseup.net>"] authors = ["Valentin Brandl <vbrandl@riseup.net>"]
edition = "2018" edition = "2018"
build = "build.rs" build = "build.rs"
@ -20,18 +20,18 @@ bytes = "1.3.0"
config = { version = "0.13.3", features = ["toml"] } config = { version = "0.13.3", features = ["toml"] }
dotenvy = "0.15.6" dotenvy = "0.15.6"
futures = "0.3.25" futures = "0.3.25"
git2 = "0.15.0" git2 = "0.16.0"
lazy_static = "1.4.0" lazy_static = "1.4.0"
mime = "0.3" mime = "0.3"
number_prefix = "0.4.0" number_prefix = "0.4.0"
openssl-probe = "0.1.5" openssl-probe = "0.1.5"
reqwest = "0.11.13" reqwest = "0.11.14"
serde = "1.0.152" serde = "1.0.152"
serde_derive = "1.0.137" serde_derive = "1.0.137"
serde_json = "1.0.91" serde_json = "1.0.91"
tracing = "0.1.37" tracing = "0.1.37"
tracing-actix-web = "0.7.1" tracing-actix-web = "0.7.2"
tracing-bunyan-formatter = "0.3.4" tracing-bunyan-formatter = "0.3.6"
tracing-futures = "0.2.5" tracing-futures = "0.2.5"
tracing-log = "0.1.3" tracing-log = "0.1.3"
tracing-subscriber = { version = "0.3.16", features = ["registry", "env-filter"] } tracing-subscriber = { version = "0.3.16", features = ["registry", "env-filter"] }
@ -44,4 +44,4 @@ vergen = { version = "7.5.0", default-features = false, features = ["git"] }
awc = "3.0.1" awc = "3.0.1"
ructe = "0.15.0" ructe = "0.15.0"
tempfile = "3.3.0" tempfile = "3.3.0"
tokio = "1.24.1" tokio = "1.24.2"

View File

@ -83,8 +83,14 @@ struct JsonResponse<'a> {
} }
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
struct BranchQuery { struct BadgeQuery {
branch: Option<String>, 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<()> { fn pull(path: impl AsRef<Path>) -> Result<()> {
@ -298,7 +304,7 @@ pub(crate) async fn json_hoc<T: Service>(
state: web::Data<State>, state: web::Data<State>,
repo_count: web::Data<AtomicUsize>, repo_count: web::Data<AtomicUsize>,
data: web::Path<(String, String)>, data: web::Path<(String, String)>,
branch: web::Query<BranchQuery>, branch: web::Query<BadgeQuery>,
) -> Result<HttpResponse> { ) -> Result<HttpResponse> {
let branch = branch.branch.as_deref().unwrap_or("master"); let branch = branch.branch.as_deref().unwrap_or("master");
let rc_clone = repo_count.clone(); let rc_clone = repo_count.clone();
@ -334,14 +340,15 @@ pub(crate) async fn calculate_hoc<T: Service>(
state: web::Data<State>, state: web::Data<State>,
repo_count: web::Data<AtomicUsize>, repo_count: web::Data<AtomicUsize>,
data: web::Path<(String, String)>, data: web::Path<(String, String)>,
branch: web::Query<BranchQuery>, query: web::Query<BadgeQuery>,
) -> HttpResponse { ) -> HttpResponse {
let rc_clone = repo_count.clone(); let rc_clone = repo_count.clone();
let label = query.label.clone();
let mapper = move |r| match r { let mapper = move |r| match r {
HocResult::NotFound => p404(rc_clone), HocResult::NotFound => p404(rc_clone),
HocResult::Hoc { hoc_pretty, .. } => { HocResult::Hoc { hoc_pretty, .. } => {
let badge_opt = BadgeOptions { let badge_opt = BadgeOptions {
subject: "Hits-of-Code".to_string(), subject: label,
color: "#007ec6".to_string(), color: "#007ec6".to_string(),
status: hoc_pretty, status: hoc_pretty,
}; };
@ -352,10 +359,10 @@ pub(crate) async fn calculate_hoc<T: Service>(
Ok(no_cache_response(body)) 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 = |_| {
let error_badge = Badge::new(BadgeOptions { let error_badge = Badge::new(BadgeOptions {
subject: "Hits-of-Code".to_string(), subject: query.label.clone(),
color: "#ff0000".to_string(), color: "#ff0000".to_string(),
status: "error".to_string(), status: "error".to_string(),
}) })
@ -372,9 +379,10 @@ async fn overview<T: Service>(
state: web::Data<State>, state: web::Data<State>,
repo_count: web::Data<AtomicUsize>, repo_count: web::Data<AtomicUsize>,
data: web::Path<(String, String)>, data: web::Path<(String, String)>,
branch: web::Query<BranchQuery>, query: web::Query<BadgeQuery>,
) -> Result<HttpResponse> { ) -> 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 base_url = state.settings.base_url.clone();
let rc_clone = repo_count.clone(); let rc_clone = repo_count.clone();
let mapper = move |r| match r { let mapper = move |r| match r {
@ -405,6 +413,7 @@ async fn overview<T: Service>(
VERSION_INFO, VERSION_INFO,
rc_clone.load(Ordering::Relaxed), rc_clone.load(Ordering::Relaxed),
repo_info, repo_info,
label,
)?; )?;
Ok(HttpResponse::Ok().content_type("text/html").body(buf)) Ok(HttpResponse::Ok().content_type("text/html").body(buf))

View File

@ -51,6 +51,10 @@ in your repository or you want a badge for another branch of your repository, ju
<code>?branch=&lt;branch-name&gt;</code> to the URL. <code>?branch=&lt;branch-name&gt;</code> to the URL.
</p> </p>
<p>
The badge label can be customized using the <code>label=&lt;some-label&gt;</code> query parameter. It defaults to <code>Hits-of-Code</code>.
</p>
<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 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 with three fields: <code>count</code> (the HoC value), <code>commits</code> (the number of commits) and

View File

@ -2,7 +2,7 @@
@use crate::statics::VersionInfo; @use crate::statics::VersionInfo;
@use crate::template::RepoInfo; @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", { @:base("Hits-of-Code Badges", "Overview", {
@ -19,7 +19,7 @@ To include the badge in your readme, use the following markdown:
</p> </p>
<pre> <pre>
[![Hits-of-Code](@repo_info.base_url/@repo_info.path?branch=@repo_info.branch)](@repo_info.base_url/@repo_info.path/view?branch=@repo_info.branch) [![@label](@repo_info.base_url/@repo_info.path?branch=@repo_info.branch&label=@label)](@repo_info.base_url/@repo_info.path/view?branch=@repo_info.branch&label=@label)
</pre> </pre>