Compare commits
185 Commits
v0.26.0
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
02c6a7ccc8 | |||
5652f46e2f | |||
140074171b | |||
519925762a | |||
e669499a6f | |||
7ef2f8f87c | |||
30ef5cf41f | |||
5c5b848177 | |||
ba72053fa1 | |||
79c94f964f | |||
36c0b08067 | |||
78383c291b | |||
fe271c764e | |||
29f9765254 | |||
70d21bd0db | |||
fdd2883f3b | |||
aff5ba2e0b | |||
5b2d1e9016 | |||
a93400ac14
|
|||
b03e316c89
|
|||
3f2a359a90
|
|||
fba01cd0c8 | |||
e67696406b
|
|||
ad9579418e | |||
540f30d472 | |||
4f9cd72115
|
|||
3612684709 | |||
0cb9deca71 | |||
52f3895af8
|
|||
d8e51e8c74
|
|||
35d2315812 | |||
7caf69b5f0
|
|||
e3f1d3ef10 | |||
a0d8618722 | |||
35232d226d
|
|||
48318ee1bc | |||
b7690c062f | |||
239f94f830
|
|||
7b772d2efd | |||
54ea0dc7c4 | |||
4bb1925fa0
|
|||
15f77906e1 | |||
b5207b0c67 | |||
583a746714
|
|||
9e9220afbb | |||
2e12c9367e | |||
d27fc2352d
|
|||
5d7e5d219a
|
|||
3ca483e2ee | |||
f670505a1b | |||
ba4574a66d | |||
06dc3a73d3 | |||
36711cbf8f | |||
6c3d6c0bfa | |||
a23d4e5192 | |||
f40d35270f | |||
8d6e60fb40 | |||
144c980e89 | |||
7e30e49240
|
|||
06ce86b4ec | |||
05b9804c86 | |||
881e09194c | |||
52764a906a | |||
f66920bda5 | |||
6186f27ea2 | |||
8250c3de35 | |||
98e9c19ace | |||
7451a2e571 | |||
51cb97c103 | |||
63967c79b9 | |||
a555e8ed48 | |||
ab32765efa | |||
938aa648e8 | |||
0b37d01594 | |||
aa8d3a0f26 | |||
aea1768f52 | |||
f5f328acf1 | |||
689ec4fe95 | |||
73db3915b3 | |||
0e4ee009c9 | |||
35d5c8531e | |||
e3bcf4f4ca | |||
a6f33097d3 | |||
4b9a0f95e3 | |||
1f340728a1 | |||
16079253b8 | |||
cb97f0feee | |||
366b3496f2 | |||
a73f07e491 | |||
4ddaa84e5f | |||
74a9f74455 | |||
fca16947f6 | |||
83a4cb57d8
|
|||
9aa9b5359a | |||
00ee175e8b
|
|||
c0bafa6079 | |||
18fb75e13e | |||
9a578565bd | |||
ffb7acc738 | |||
8b058d9c53 | |||
30906da803 | |||
665db0b8c5 | |||
558137e2ee | |||
4708c19eb1 | |||
0e12778ea3
|
|||
fe2fc171ce | |||
061d7f8e07 | |||
cd5eaeefbf | |||
a0e4e5be88 | |||
f179bd875e
|
|||
7445bdd29d | |||
44a40cb086 | |||
2c23df798f
|
|||
3c5c206f9b
|
|||
c03d297b6b | |||
ca640fc6ad
|
|||
6c2e158310 | |||
68bc22e990 | |||
c1bf500c9b
|
|||
d21bcd7946 | |||
51ff4c2ebb | |||
862e928262 | |||
fb149da06c | |||
872a81d6c2 | |||
20828c7db4
|
|||
a88600f02a | |||
b392a05b42 | |||
52fea6787b
|
|||
713b0487fc | |||
8d7c769d84 | |||
566fcf181b
|
|||
2d9c2b7097 | |||
b7237a6a16 | |||
0a2d77920e | |||
6198dcf26d | |||
51236eee78 | |||
3db8f6830b | |||
8b19bdc0ae | |||
eab043194a | |||
13b3611a65
|
|||
0d7f435d49
|
|||
eec82fa04a | |||
c2cf11d794
|
|||
f5f9a4a0d3 | |||
554f0d21cf
|
|||
db78428191 | |||
22bc5496f1 | |||
3bb1784e52
|
|||
6a5dec8cb7 | |||
41a0d64b65 | |||
a5249e2a64
|
|||
f053c6bbf7 | |||
dd16ed862b | |||
65dc0205d0
|
|||
0100b754f4
|
|||
8d90ffff1e | |||
2bec463cbe | |||
e49135f128 | |||
f00b20dd19 | |||
d98bfcd55a | |||
ea96746a54 | |||
08ff91324c | |||
30e97ddc51 | |||
6d4ec8f546 | |||
499362cbce | |||
51ba8c19b4 | |||
33d1eb784e | |||
111a9720d6 | |||
e9c8612f62 | |||
f6b48c6ac6 | |||
afc357c025 | |||
7aec5d5045 | |||
502dda0b6e | |||
40831cfa57 | |||
b841816173 | |||
6e38e92f52 | |||
fa323161e5 | |||
4697035936 | |||
19b7ae0e6b | |||
ecf052c73b | |||
7d297fc456 | |||
a2a8261095 | |||
8aac012161 | |||
c05843f07a | |||
9df487ef1b |
164
CHANGELOG.md
164
CHANGELOG.md
@ -5,6 +5,170 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
* Updated [`tracing-actix-web`](https://github.com/LukeMathWalker/tracing-actix-web) from 0.7.2 to 0.7.3 ([#578])
|
||||||
|
* Updated [`serde`](https://github.com/serde-rs/serde) from 1.0.156 to 1.0.158 ([#580])
|
||||||
|
* Updated [`mime`](https://github.com/hyperium/mime) from 0.3.16 to 0.3.17 ([#582])
|
||||||
|
* Updated [`dotenvy`](https://github.com/allan2/dotenvy) from 0.15.6 to 0.15.7 ([#583])
|
||||||
|
* Updated [`reqwest`](https://github.com/seanmonstar/reqwest) from 0.11.14 to 0.11.16 ([#586])
|
||||||
|
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.26.0 to 1.27.0 ([#588])
|
||||||
|
|
||||||
|
[#578]: https://github.com/vbrandl/hoc/pull/578
|
||||||
|
[#580]: https://github.com/vbrandl/hoc/pull/580
|
||||||
|
[#582]: https://github.com/vbrandl/hoc/pull/582
|
||||||
|
[#583]: https://github.com/vbrandl/hoc/pull/583
|
||||||
|
[#586]: https://github.com/vbrandl/hoc/pull/586
|
||||||
|
[#588]: https://github.com/vbrandl/hoc/pull/588
|
||||||
|
|
||||||
|
|
||||||
|
## [0.33.0] 2023-03-16
|
||||||
|
|
||||||
|
* Updated [`futures`](https://github.com/rust-lang/futures-rs) from 0.3.26 to 0.3.27 ([#575])
|
||||||
|
* Updated [`serde`](https://github.com/serde-rs/serde) from 1.0.152 to 1.0.156 ([#576])
|
||||||
|
* Use edition 2021 ([#577])
|
||||||
|
|
||||||
|
|
||||||
|
[#575]: https://github.com/vbrandl/hoc/pull/575
|
||||||
|
[#576]: https://github.com/vbrandl/hoc/pull/576
|
||||||
|
[#577]: https://github.com/vbrandl/hoc/pull/577
|
||||||
|
|
||||||
|
|
||||||
|
## [0.32.0] 2023-03-06
|
||||||
|
|
||||||
|
* Updated [`actix-web`](https://github.com/actix/actix-web) from 4.3.0 to 4.3.1 ([#566])
|
||||||
|
* Updated [`tempfile`](https://github.com/Stebalien/tempfile) from 3.3.0 to 3.4.0 ([#567])
|
||||||
|
* Updated [`awc`](https://github.com/actix/actix-web) from 3.1.0 to 3.1.1 ([#568])
|
||||||
|
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.25.0 to 1.26.0 ([#569])
|
||||||
|
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.93 to 1.0.94 ([#570])
|
||||||
|
|
||||||
|
[#566]: https://github.com/vbrandl/hoc/pull/566
|
||||||
|
[#567]: https://github.com/vbrandl/hoc/pull/567
|
||||||
|
[#568]: https://github.com/vbrandl/hoc/pull/568
|
||||||
|
[#569]: https://github.com/vbrandl/hoc/pull/569
|
||||||
|
[#570]: https://github.com/vbrandl/hoc/pull/570
|
||||||
|
|
||||||
|
|
||||||
|
## [0.31.0] 2023-02-13
|
||||||
|
|
||||||
|
### Dependency Updates
|
||||||
|
|
||||||
|
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.24.1 to 1.24.2 ([#547])
|
||||||
|
* Updated [`badgers`](https://github.com/vbrandl/badgers) from 1.1.0 to 1.2.0 ([#548])
|
||||||
|
* Updated [`reqwest`](https://github.com/seanmonstar/reqwest) from 0.11.13 to 0.11.14 ([#549])
|
||||||
|
* Updated [`bumpalo`](https://github.com/fitzgen/bumpalo) from 3.10.0 to 3.12.0 ([#550])
|
||||||
|
* Updated [`libgit2-sys`](https://github.com/rust-lang/git2-rs) from 0.14.1+1.5.0 to 0.14.2+1.5.1 ([#551])
|
||||||
|
* Updated [`git2`](https://github.com/rust-lang/git2-rs) from 0.16.0 to 0.16.1 ([#552])
|
||||||
|
* Updated [`actix-rt`](https://github.com/actix/actix-net) from 2.7.0 to 2.8.0 ([#553])
|
||||||
|
* Updated [`actix-web`](https://github.com/actix/actix-web) from 4.2.1 to 4.3.0 ([#554])
|
||||||
|
* Updated [`awc`](https://github.com/actix/actix-web) from 3.0.1 to 3.1.0 ([#555])
|
||||||
|
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.24.2 to 1.25.0 ([#558])
|
||||||
|
* Updated [`ructe`](https://github.com/kaj/ructe) from 0.15.0 to 0.16.1 ([#559])
|
||||||
|
* Updated [`futures`](https://github.com/rust-lang/futures-rs) from 0.3.25 to 0.3.26 ([#560])
|
||||||
|
* Updated [`bytes`](https://github.com/tokio-rs/bytes) from 1.3.0 to 1.4.0 ([#561])
|
||||||
|
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.91 to 1.0.92 ([#562])
|
||||||
|
* Updated [`vergen`](https://github.com/rustyhorde/vergen) from 7.5.0 to 7.5.1 ([#563])
|
||||||
|
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.92 to 1.0.93 ([#564])
|
||||||
|
|
||||||
|
[#547]: https://github.com/vbrandl/hoc/pull/547
|
||||||
|
[#548]: https://github.com/vbrandl/hoc/pull/548
|
||||||
|
[#550]: https://github.com/vbrandl/hoc/pull/550
|
||||||
|
[#551]: https://github.com/vbrandl/hoc/pull/551
|
||||||
|
[#552]: https://github.com/vbrandl/hoc/pull/552
|
||||||
|
[#553]: https://github.com/vbrandl/hoc/pull/553
|
||||||
|
[#554]: https://github.com/vbrandl/hoc/pull/554
|
||||||
|
[#555]: https://github.com/vbrandl/hoc/pull/555
|
||||||
|
[#558]: https://github.com/vbrandl/hoc/pull/558
|
||||||
|
[#559]: https://github.com/vbrandl/hoc/pull/559
|
||||||
|
[#560]: https://github.com/vbrandl/hoc/pull/560
|
||||||
|
[#561]: https://github.com/vbrandl/hoc/pull/561
|
||||||
|
[#562]: https://github.com/vbrandl/hoc/pull/562
|
||||||
|
[#563]: https://github.com/vbrandl/hoc/pull/563
|
||||||
|
[#564]: https://github.com/vbrandl/hoc/pull/564
|
||||||
|
|
||||||
|
|
||||||
|
## [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
|
||||||
|
|
||||||
|
### Dependency Updates
|
||||||
|
|
||||||
|
* Updated [`badgers`](https://github.com/vbrandl/badgers) from 1.0.0 to 1.1.0 ([#530])
|
||||||
|
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.90 to 1.0.91 ([#531])
|
||||||
|
* Updated [`vergen`](https://github.com/rustyhorde/vergen) from 7.3.1 to 7.4.4 ([#533])
|
||||||
|
* Updated [`tracing-actix-web`](https://github.com/LukeMathWalker/tracing-actix-web) from 0.6.2 to 0.7.1 ([#534])
|
||||||
|
* Updated [`serde`](https://github.com/serde-rs/serde) from 1.0.151 to 1.0.152 ([#535])
|
||||||
|
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.23.0 to 1.23.1 ([#536])
|
||||||
|
* Updated [`vergen`](https://github.com/rustyhorde/vergen) from 7.4.4 to 7.5.0 ([#537])
|
||||||
|
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.23.1 to 1.24.1 ([#539])
|
||||||
|
|
||||||
|
[#530]: https://github.com/vbrandl/hoc/pull/530
|
||||||
|
[#531]: https://github.com/vbrandl/hoc/pull/531
|
||||||
|
[#533]: https://github.com/vbrandl/hoc/pull/533
|
||||||
|
[#534]: https://github.com/vbrandl/hoc/pull/534
|
||||||
|
[#535]: https://github.com/vbrandl/hoc/pull/535
|
||||||
|
[#536]: https://github.com/vbrandl/hoc/pull/536
|
||||||
|
[#537]: https://github.com/vbrandl/hoc/pull/537
|
||||||
|
[#539]: https://github.com/vbrandl/hoc/pull/539
|
||||||
|
|
||||||
|
## [0.28.0] 2022-12-18
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
* Fixed clippy lint `needless_borrow` ([#526])
|
||||||
|
|
||||||
|
### Dependency Updates
|
||||||
|
|
||||||
|
* Updated [`bytes`](https://github.com/tokio-rs/bytes) from 1.2.1 to 1.3.0 ([#519])
|
||||||
|
* Updated [`config`](https://github.com/mehcode/config-rs) from 0.13.2 to 0.13.3 ([#522])
|
||||||
|
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.88 to 1.0.90 ([#527])
|
||||||
|
* Updated [`serde`](https://github.com/serde-rs/serde) from 1.0.147 to 1.0.151 ([#528])
|
||||||
|
|
||||||
|
[#519]: https://github.com/vbrandl/hoc/pull/519
|
||||||
|
[#522]: https://github.com/vbrandl/hoc/pull/522
|
||||||
|
[#526]: https://github.com/vbrandl/hoc/pull/526
|
||||||
|
[#527]: https://github.com/vbrandl/hoc/pull/527
|
||||||
|
[#528]: https://github.com/vbrandl/hoc/pull/528
|
||||||
|
|
||||||
|
## [0.27.0] 2022-10-21
|
||||||
|
|
||||||
|
### Dependency Updates
|
||||||
|
|
||||||
|
* Updated [`futures`](https://github.com/rust-lang/futures-rs) from 0.3.24 to 0.3.25 ([#511])
|
||||||
|
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.86 to 1.0.87 ([#510])
|
||||||
|
* Updated [`serde`](https://github.com/serde-rs/serde) from 1.0.145 to 1.0.147 ([#512])
|
||||||
|
* Updated [`tracing-actix-web`](https://github.com/LukeMathWalker/tracing-actix-web) from 0.6.1 to 0.6.2 ([#513])
|
||||||
|
* Updated [`reqwest`](https://github.com/seanmonstar/reqwest) from 0.11.12 to 0.11.13 ([#515])
|
||||||
|
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.21.2 to 1.22.0 ([#516])
|
||||||
|
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.87 to 1.0.88 ([#517])
|
||||||
|
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
* Fix clippy lint `needless-borrow` ([#514])
|
||||||
|
|
||||||
|
[#511]: https://github.com/vbrandl/hoc/pull/511
|
||||||
|
[#510]: https://github.com/vbrandl/hoc/pull/510
|
||||||
|
[#512]: https://github.com/vbrandl/hoc/pull/512
|
||||||
|
[#513]: https://github.com/vbrandl/hoc/pull/513
|
||||||
|
[#514]: https://github.com/vbrandl/hoc/pull/514
|
||||||
|
[#515]: https://github.com/vbrandl/hoc/pull/515
|
||||||
|
[#516]: https://github.com/vbrandl/hoc/pull/516
|
||||||
|
[#517]: https://github.com/vbrandl/hoc/pull/517
|
||||||
|
|
||||||
|
|
||||||
## [0.26.0] 2022-10-03
|
## [0.26.0] 2022-10-03
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
469
Cargo.lock
generated
469
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
42
Cargo.toml
42
Cargo.toml
@ -1,8 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "hoc"
|
name = "hoc"
|
||||||
version = "0.26.0"
|
version = "0.33.0"
|
||||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
@ -13,35 +13,35 @@ path = "src/main.rs"
|
|||||||
name = "hoc"
|
name = "hoc"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-rt = "2.7.0"
|
actix-rt = "2.8.0"
|
||||||
actix-web = "4.2.1"
|
actix-web = "4.3.1"
|
||||||
badgers = "1.0.0"
|
badgers = "1.2.0"
|
||||||
bytes = "1.2.1"
|
bytes = "1.4.0"
|
||||||
config = { version = "0.13.2", features = ["toml"] }
|
config = { version = "0.13.3", features = ["toml"] }
|
||||||
dotenvy = "0.15.6"
|
dotenvy = "0.15.7"
|
||||||
futures = "0.3.24"
|
futures = "0.3.27"
|
||||||
git2 = "0.15.0"
|
git2 = "0.16.1"
|
||||||
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.12"
|
reqwest = "0.11.16"
|
||||||
serde = "1.0.145"
|
serde = "1.0.158"
|
||||||
serde_derive = "1.0.137"
|
serde_derive = "1.0.137"
|
||||||
serde_json = "1.0.86"
|
serde_json = "1.0.94"
|
||||||
tracing = "0.1.37"
|
tracing = "0.1.37"
|
||||||
tracing-actix-web = "0.6.1"
|
tracing-actix-web = "0.7.3"
|
||||||
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"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
ructe = { version = "0.15.0", features = ["mime03"] }
|
ructe = { version = "0.16.1", features = ["mime03"] }
|
||||||
vergen = { version = "7.3.1", default-features = false, features = ["git"] }
|
vergen = { version = "7.5.1", default-features = false, features = ["git"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
awc = "3.0.1"
|
awc = "3.1.1"
|
||||||
ructe = "0.15.0"
|
ructe = "0.16.1"
|
||||||
tempfile = "3.3.0"
|
tempfile = "3.4.0"
|
||||||
tokio = "1.21.2"
|
tokio = "1.27.0"
|
||||||
|
16
src/error.rs
16
src/error.rs
@ -19,13 +19,13 @@ pub enum Error {
|
|||||||
impl fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Error::Badge(s) => write!(fmt, "Badge({})", s),
|
Error::Badge(s) => write!(fmt, "Badge({s})"),
|
||||||
Error::Client(e) => write!(fmt, "Client({})", e),
|
Error::Client(e) => write!(fmt, "Client({e})"),
|
||||||
Error::Git(e) => write!(fmt, "Git({})", e),
|
Error::Git(e) => write!(fmt, "Git({e})"),
|
||||||
Error::Internal => write!(fmt, "Internal Error"),
|
Error::Internal => write!(fmt, "Internal Error"),
|
||||||
Error::Io(e) => write!(fmt, "Io({})", e),
|
Error::Io(e) => write!(fmt, "Io({e})"),
|
||||||
Error::Parse(e) => write!(fmt, "Parse({})", e),
|
Error::Parse(e) => write!(fmt, "Parse({e})"),
|
||||||
Error::Serial(e) => write!(fmt, "Serial({})", e),
|
Error::Serial(e) => write!(fmt, "Serial({e})"),
|
||||||
Error::BranchNotFound => write!(fmt, "Repo doesn't have master branch"),
|
Error::BranchNotFound => write!(fmt, "Repo doesn't have master branch"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,11 +43,11 @@ impl ResponseError for Error {
|
|||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
match self {
|
match self {
|
||||||
Error::BranchNotFound => {
|
Error::BranchNotFound => {
|
||||||
templates::p404_no_master(&mut buf, VERSION_INFO, 0).unwrap();
|
templates::p404_no_master_html(&mut buf, VERSION_INFO, 0).unwrap();
|
||||||
HttpResponse::NotFound().content_type("text/html").body(buf)
|
HttpResponse::NotFound().content_type("text/html").body(buf)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
templates::p500(&mut buf, VERSION_INFO, 0).unwrap();
|
templates::p500_html(&mut buf, VERSION_INFO, 0).unwrap();
|
||||||
HttpResponse::InternalServerError()
|
HttpResponse::InternalServerError()
|
||||||
.content_type("text/html")
|
.content_type("text/html")
|
||||||
.body(buf)
|
.body(buf)
|
||||||
|
61
src/lib.rs
61
src/lib.rs
@ -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<()> {
|
||||||
@ -95,8 +101,8 @@ fn pull(path: impl AsRef<Path>) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn hoc(repo: &str, repo_dir: &str, cache_dir: &str, branch: &str) -> Result<(u64, String, u64)> {
|
fn hoc(repo: &str, repo_dir: &str, cache_dir: &str, branch: &str) -> Result<(u64, String, u64)> {
|
||||||
let repo_dir = format!("{}/{}", repo_dir, repo);
|
let repo_dir = format!("{repo_dir}/{repo}");
|
||||||
let cache_dir = format!("{}/{}.json", cache_dir, repo);
|
let cache_dir = format!("{cache_dir}/{repo}.json");
|
||||||
let cache_dir = Path::new(&cache_dir);
|
let cache_dir = Path::new(&cache_dir);
|
||||||
let repo = Repository::open_bare(&repo_dir)?;
|
let repo = Repository::open_bare(&repo_dir)?;
|
||||||
// TODO: do better...
|
// TODO: do better...
|
||||||
@ -118,7 +124,7 @@ fn hoc(repo: &str, repo_dir: &str, cache_dir: &str, branch: &str) -> Result<(u64
|
|||||||
"-M".to_string(),
|
"-M".to_string(),
|
||||||
"--diff-filter=ACDM".to_string(),
|
"--diff-filter=ACDM".to_string(),
|
||||||
];
|
];
|
||||||
let cache = CacheState::read_from_file(&cache_dir, branch, &head)?;
|
let cache = CacheState::read_from_file(cache_dir, branch, &head)?;
|
||||||
match &cache {
|
match &cache {
|
||||||
CacheState::Current { count, commits, .. } => {
|
CacheState::Current { count, commits, .. } => {
|
||||||
info!("Using cache");
|
info!("Using cache");
|
||||||
@ -126,8 +132,8 @@ fn hoc(repo: &str, repo_dir: &str, cache_dir: &str, branch: &str) -> Result<(u64
|
|||||||
}
|
}
|
||||||
CacheState::Old { head, .. } => {
|
CacheState::Old { head, .. } => {
|
||||||
info!("Updating cache");
|
info!("Updating cache");
|
||||||
arg.push(format!("{}..{}", head, branch));
|
arg.push(format!("{head}..{branch}"));
|
||||||
arg_commit_count.push(format!("{}..{}", head, branch));
|
arg_commit_count.push(format!("{head}..{branch}"));
|
||||||
}
|
}
|
||||||
CacheState::No | CacheState::NoneForBranch(..) => {
|
CacheState::No | CacheState::NoneForBranch(..) => {
|
||||||
info!("Creating cache");
|
info!("Creating cache");
|
||||||
@ -208,16 +214,16 @@ where
|
|||||||
data.1.to_lowercase()
|
data.1.to_lowercase()
|
||||||
);
|
);
|
||||||
info!("Deleting cache and repository");
|
info!("Deleting cache and repository");
|
||||||
let cache_dir = format!("{}/{}.json", &state.cache(), repo);
|
let cache_dir = format!("{}/{repo}.json", &state.cache());
|
||||||
let repo_dir = format!("{}/{}", &state.repos(), repo);
|
let repo_dir = format!("{}/{repo}", &state.repos());
|
||||||
std::fs::remove_file(&cache_dir).or_else(|e| {
|
std::fs::remove_file(cache_dir).or_else(|e| {
|
||||||
if e.kind() == io::ErrorKind::NotFound {
|
if e.kind() == io::ErrorKind::NotFound {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(e)
|
Err(e)
|
||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
std::fs::remove_dir_all(&repo_dir).or_else(|e| {
|
std::fs::remove_dir_all(repo_dir).or_else(|e| {
|
||||||
if e.kind() == io::ErrorKind::NotFound {
|
if e.kind() == io::ErrorKind::NotFound {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
@ -256,10 +262,10 @@ where
|
|||||||
);
|
);
|
||||||
let future = async {
|
let future = async {
|
||||||
let repo = format!("{}/{}", data.0.to_lowercase(), data.1.to_lowercase());
|
let repo = format!("{}/{}", data.0.to_lowercase(), data.1.to_lowercase());
|
||||||
let service_path = format!("{}/{}", T::url_path(), repo);
|
let service_path = format!("{}/{repo}", T::url_path());
|
||||||
let service_url = format!("{}/{}", T::domain(), repo);
|
let service_url = format!("{}/{repo}", T::domain());
|
||||||
let path = format!("{}/{}", state.repos(), service_url);
|
let path = format!("{}/{service_url}", state.repos());
|
||||||
let url = format!("https://{}", service_url);
|
let url = format!("https://{service_url}");
|
||||||
let remote_exists = remote_exists(&url).await?;
|
let remote_exists = remote_exists(&url).await?;
|
||||||
let file = Path::new(&path);
|
let file = Path::new(&path);
|
||||||
if !file.exists() {
|
if !file.exists() {
|
||||||
@ -278,7 +284,7 @@ where
|
|||||||
let (hoc, head, commits) = hoc(&service_url, &state.repos(), &state.cache(), branch)?;
|
let (hoc, head, commits) = hoc(&service_url, &state.repos(), &state.cache(), branch)?;
|
||||||
let hoc_pretty = match NumberPrefix::decimal(hoc as f64) {
|
let hoc_pretty = match NumberPrefix::decimal(hoc as f64) {
|
||||||
NumberPrefix::Standalone(hoc) => hoc.to_string(),
|
NumberPrefix::Standalone(hoc) => hoc.to_string(),
|
||||||
NumberPrefix::Prefixed(prefix, hoc) => format!("{:.1}{}", hoc, prefix),
|
NumberPrefix::Prefixed(prefix, hoc) => format!("{hoc:.1}{prefix}"),
|
||||||
};
|
};
|
||||||
let res = HocResult::Hoc {
|
let res = HocResult::Hoc {
|
||||||
hoc,
|
hoc,
|
||||||
@ -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 {
|
||||||
@ -400,11 +408,12 @@ async fn overview<T: Service>(
|
|||||||
url: &url,
|
url: &url,
|
||||||
branch,
|
branch,
|
||||||
};
|
};
|
||||||
templates::overview(
|
templates::overview_html(
|
||||||
&mut buf,
|
&mut buf,
|
||||||
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))
|
||||||
@ -424,7 +433,7 @@ async fn index(
|
|||||||
repo_count: web::Data<AtomicUsize>,
|
repo_count: web::Data<AtomicUsize>,
|
||||||
) -> Result<HttpResponse> {
|
) -> Result<HttpResponse> {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
templates::index(
|
templates::index_html(
|
||||||
&mut buf,
|
&mut buf,
|
||||||
VERSION_INFO,
|
VERSION_INFO,
|
||||||
repo_count.load(Ordering::Relaxed),
|
repo_count.load(Ordering::Relaxed),
|
||||||
@ -450,7 +459,7 @@ async fn generate(
|
|||||||
.filter(|s| !s.is_empty())
|
.filter(|s| !s.is_empty())
|
||||||
.unwrap_or("master"),
|
.unwrap_or("master"),
|
||||||
};
|
};
|
||||||
templates::generate(
|
templates::generate_html(
|
||||||
&mut buf,
|
&mut buf,
|
||||||
VERSION_INFO,
|
VERSION_INFO,
|
||||||
repo_count.load(Ordering::Relaxed),
|
repo_count.load(Ordering::Relaxed),
|
||||||
@ -463,7 +472,7 @@ async fn generate(
|
|||||||
|
|
||||||
fn p404(repo_count: web::Data<AtomicUsize>) -> Result<HttpResponse> {
|
fn p404(repo_count: web::Data<AtomicUsize>) -> Result<HttpResponse> {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
templates::p404(&mut buf, VERSION_INFO, repo_count.load(Ordering::Relaxed))?;
|
templates::p404_html(&mut buf, VERSION_INFO, repo_count.load(Ordering::Relaxed))?;
|
||||||
Ok(HttpResponse::NotFound().content_type("text/html").body(buf))
|
Ok(HttpResponse::NotFound().content_type("text/html").body(buf))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
@use super::base;
|
@use super::base_html;
|
||||||
@use crate::{statics::VersionInfo, template::RepoGeneratorInfo};
|
@use crate::{statics::VersionInfo, template::RepoGeneratorInfo};
|
||||||
|
|
||||||
@(version_info: VersionInfo, repo_count: usize, base_url: &str, repo_info: &RepoGeneratorInfo)
|
@(version_info: VersionInfo, repo_count: usize, base_url: &str, repo_info: &RepoGeneratorInfo)
|
||||||
|
|
||||||
@:base("Hits-of-Code Badges", "Badge Generator", {
|
@:base_html("Hits-of-Code Badges", "Badge Generator", {
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Here is the markdown for the badge for <a href="https://@repo_info.service.url()/@repo_info.user/@repo_info.repo">@repo_info.user/@repo_info.repo</a>
|
Here is the markdown for the badge for <a href="https://@repo_info.service.url()/@repo_info.user/@repo_info.repo">@repo_info.user/@repo_info.repo</a>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
@use super::base;
|
@use super::base_html;
|
||||||
@use crate::statics::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, repo_count: usize, base_url: &str)
|
@(version_info: VersionInfo, repo_count: usize, base_url: &str)
|
||||||
|
|
||||||
@:base("Hits-of-Code Badges", "Hits-of-Code Badges", {
|
@:base_html("Hits-of-Code Badges", "Hits-of-Code Badges", {
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
This API offers badges for the Hits-of-Code metric for your repositories. This metric was proposed by
|
This API offers badges for the Hits-of-Code metric for your repositories. This metric was proposed by
|
||||||
@ -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.
|
<code>?branch=<branch-name></code> to the URL.
|
||||||
</p>
|
</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>
|
<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
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
@use super::base;
|
@use super::base_html;
|
||||||
@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_html("Hits-of-Code Badges", "Overview", {
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The project <a href="@repo_info.url">@repo_info.url</a> has
|
The project <a href="@repo_info.url">@repo_info.url</a> has
|
||||||
@ -19,7 +19,7 @@ To include the badge in your readme, use the following markdown:
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<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>
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
@use super::base;
|
@use super::base_html;
|
||||||
@use crate::statics::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, repo_count: usize)
|
@(version_info: VersionInfo, repo_count: usize)
|
||||||
|
|
||||||
@:base("Page not Found - Hits-of-Code Badges", "404 - Page not Found", {
|
@:base_html("Page not Found - Hits-of-Code Badges", "404 - Page not Found", {
|
||||||
<p>
|
<p>
|
||||||
<big>Sorry</big>. I couldn't find the page you are looking for. Please go <a href="/">back to the homepage</a>.
|
<big>Sorry</big>. I couldn't find the page you are looking for. Please go <a href="/">back to the homepage</a>.
|
||||||
</p>
|
</p>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
@use super::base;
|
@use super::base_html;
|
||||||
@use crate::statics::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, repo_count: usize)
|
@(version_info: VersionInfo, repo_count: usize)
|
||||||
|
|
||||||
@:base("Branch not Found - Hits-of-Code Badges", "404 - Branch not Found", {
|
@:base_html("Branch not Found - Hits-of-Code Badges", "404 - Branch not Found", {
|
||||||
<p>
|
<p>
|
||||||
<big>Sorry</big>. I couldn't find the requested branch of your repositroy. Currently this service assumes the
|
<big>Sorry</big>. I couldn't find the requested branch of your repositroy. Currently this service assumes the
|
||||||
extistence of a branch named <code>master</code>. If you'd like to request a badge for another branch, you can do so by
|
extistence of a branch named <code>master</code>. If you'd like to request a badge for another branch, you can do so by
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
@use super::base;
|
@use super::base_html;
|
||||||
@use crate::statics::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, repo_count: usize)
|
@(version_info: VersionInfo, repo_count: usize)
|
||||||
|
|
||||||
@:base("Internal Server Error - Hits-of-Code Badges", "500 - Internal Server Error", {
|
@:base_html("Internal Server Error - Hits-of-Code Badges", "500 - Internal Server Error", {
|
||||||
<p>
|
<p>
|
||||||
<big>Oops</big>. Looks like a made a mistake. Please go <a href="/">back to the homepage</a> and try again.
|
<big>Oops</big>. Looks like a made a mistake. Please go <a href="/">back to the homepage</a> and try again.
|
||||||
</p>
|
</p>
|
||||||
|
Reference in New Issue
Block a user