Compare commits
211 Commits
release/v0
...
fix/rust-c
Author | SHA1 | Date | |
---|---|---|---|
87bae1bbd1 | |||
a64f55f362 | |||
9f3c2813ab | |||
4ce8c9e523 | |||
361eacbe1d | |||
b07c732475 | |||
fddb3dd3d6 | |||
f433f27229 | |||
8d7e97ba11 | |||
59ce8e2b57 | |||
2e5dcf4ef5 | |||
739162d2cd | |||
4be1d9881b | |||
f9e5175773 | |||
96ca6bda04 | |||
df96fcb091 | |||
1bae5a2b99 | |||
5924f2ab23 | |||
202c9ba03e | |||
8123b59e33 | |||
7bb8e82c3b | |||
5f1fc70a05 | |||
d60462f7ce | |||
4ce55c8e32 | |||
1a8db00ce4 | |||
c304164935 | |||
e2594b3c5b | |||
12c400e5b8 | |||
745a9021cd | |||
4bb0c8adc7 | |||
e7cf23c625 | |||
78078132ce | |||
6aa253d44e | |||
d461a8f6a1 | |||
4847cc4f1f | |||
bef518d594 | |||
c22cc59924 | |||
a4e28984ef | |||
f4372c3248 | |||
e9554a20a7 | |||
7862446e16 | |||
b4a7444442 | |||
66861cb4d3 | |||
e6b1dfece8
|
|||
6837660a79 | |||
109886ad9a | |||
dcadae98b6 | |||
4845826023 | |||
ce9db6b4a7
|
|||
24f2d43550
|
|||
43bbf4d377 | |||
23d346d899 | |||
9186de3b53 | |||
59b1ff41fc | |||
17016c39bf | |||
6041c5367b | |||
5914f9d1ad | |||
ee069dd079 | |||
82bc044321 | |||
f4895d8c3b | |||
0d9be14496 | |||
ef769c9d5a | |||
bcf21906c8
|
|||
abe637f878 | |||
bcc9d77622 | |||
ac88f591b0
|
|||
38cf6cbf6b | |||
1b06818a66 | |||
7de5a420d2
|
|||
b546ee6682 | |||
19fb89b5a2 | |||
90bb04386e | |||
eb35e745de | |||
41ecaa8ac9 | |||
6f23f4c13d | |||
f1640fdc36 | |||
3f6fb6bac9 | |||
3b51b2c7df
|
|||
d0ce2c7f89 | |||
b14e6cbf71 | |||
a9b7368847 | |||
b3cc22af6c | |||
037e520beb
|
|||
119dcd4cff | |||
081ca836bc
|
|||
62114219e2
|
|||
38b86aa490 | |||
88eab864b1 | |||
864cbe1c73 | |||
ced16e2e6b | |||
834085df92 | |||
fd3746e781 | |||
45b45eebc2 | |||
914ee4b637 | |||
e57294ff4c | |||
7129c8f9c4 | |||
80235319b8 | |||
68b31cbcdb | |||
1fabfdc27c | |||
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 |
12
.github/dependabot.yml
vendored
12
.github/dependabot.yml
vendored
@ -10,3 +10,15 @@ updates:
|
|||||||
- vbrandl
|
- vbrandl
|
||||||
labels:
|
labels:
|
||||||
- dependencies
|
- dependencies
|
||||||
|
- dependabot
|
||||||
|
|
||||||
|
- package-ecosystem: 'github-actions'
|
||||||
|
directory: '/'
|
||||||
|
schedule:
|
||||||
|
interval: 'daily'
|
||||||
|
open-pull-requests-limit: 10
|
||||||
|
assignees:
|
||||||
|
- vbrandl
|
||||||
|
labels:
|
||||||
|
- dependabot
|
||||||
|
- dependencies
|
||||||
|
2
.github/workflows/audit.yml
vendored
2
.github/workflows/audit.yml
vendored
@ -16,6 +16,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions-rs/audit-check@v1
|
- uses: rustsec/audit-check@v1
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
26
.github/workflows/dependabot-changelog.yml
vendored
Normal file
26
.github/workflows/dependabot-changelog.yml
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
name: 'Dependabot Changelog'
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
- labeled
|
||||||
|
- unlabeled
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
changelog:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.ACTION_TOKEN }}
|
||||||
|
- uses: dangoslen/dependabot-changelog-helper@v3
|
||||||
|
with:
|
||||||
|
activationLabel: 'dependabot'
|
||||||
|
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
|
with:
|
||||||
|
commit_message: "Update Changelog"
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -42,7 +42,7 @@ jobs:
|
|||||||
override: true
|
override: true
|
||||||
|
|
||||||
- name: Cache cargo registry, index and build directory
|
- name: Cache cargo registry, index and build directory
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo/registry
|
~/.cargo/registry
|
||||||
|
41
.github/workflows/rust.yml
vendored
41
.github/workflows/rust.yml
vendored
@ -16,18 +16,11 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install stable toolchain
|
- name: Install stable toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
profile: minimal
|
|
||||||
override: true
|
|
||||||
components: rustfmt
|
|
||||||
|
|
||||||
- name: Check Formatting
|
- name: Check Formatting
|
||||||
uses: actions-rs/cargo@v1
|
run: cargo fmt --all -- --check
|
||||||
with:
|
|
||||||
command: fmt
|
|
||||||
args: --all -- --check
|
|
||||||
|
|
||||||
clippy:
|
clippy:
|
||||||
name: Clippy
|
name: Clippy
|
||||||
@ -37,12 +30,7 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install stable toolchain
|
- name: Install stable toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
profile: minimal
|
|
||||||
override: true
|
|
||||||
components: rustfmt
|
|
||||||
|
|
||||||
- name: Cache cargo registry, index and build directory
|
- name: Cache cargo registry, index and build directory
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
@ -54,10 +42,13 @@ jobs:
|
|||||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
- name: Clippy Linting
|
- name: Clippy Linting
|
||||||
uses: actions-rs/cargo@v1
|
run: cargo clippy --all-features -- -Dclippy::all
|
||||||
with:
|
# TODO
|
||||||
command: clippy
|
# run: cargo clippy --all-features -- -Dclippy::all -Dclippy::pedantic
|
||||||
args: -- -D warnings
|
- name: Clippy Test Linting
|
||||||
|
run: cargo clippy --tests -- -Dclippy::all
|
||||||
|
# TODO
|
||||||
|
# run: cargo clippy --tests -- -Dclippy::all -Dclippy::pedantic
|
||||||
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@ -74,11 +65,7 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install stable toolchain
|
- name: Install stable toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
profile: minimal
|
|
||||||
override: true
|
|
||||||
|
|
||||||
- name: Cache cargo registry, index and build directory
|
- name: Cache cargo registry, index and build directory
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
@ -90,6 +77,4 @@ jobs:
|
|||||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
uses: actions-rs/cargo@v1
|
run: cargo test
|
||||||
with:
|
|
||||||
command: test
|
|
||||||
|
150
CHANGELOG.md
150
CHANGELOG.md
@ -4,8 +4,156 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
### Dependencies
|
||||||
|
- Bump `serde` from 1.0.160 to 1.0.164 (#613, #617, #627)
|
||||||
|
- Bump `actions/cache` from 2 to 3 (#616)
|
||||||
|
- Bump `tokio` from 1.28.0 to 1.28.2 (#618, #625)
|
||||||
|
- Bump `reqwest` from 0.11.17 to 0.11.18 (#619)
|
||||||
|
- Bump `vergen` from 8.1.3 to 8.2.1 (#621, #622)
|
||||||
|
- Bump `tracing-actix-web` from 0.7.4 to 0.7.5 (#623)
|
||||||
|
- Bump `git2` from 0.17.1 to 0.17.2 (#624)
|
||||||
|
- Bump `tempfile` from 3.5.0 to 3.6.0 (#626)
|
||||||
|
|
||||||
|
|
||||||
|
## [0.35.0] 2023-05-04
|
||||||
|
|
||||||
|
* Updated [`h2`](https://github.com/hyperium/h2) from 0.3.16 to 0.3.17, fixes [SEC#11] ([#599])
|
||||||
|
* Updated [`git2`](https://github.com/rust-lang/git2-rs) from 0.16.1 to 0.17.0 ([#602])
|
||||||
|
* Updated [`git2`](https://github.com/rust-lang/git2-rs) from 0.17.0 to 0.17.1 ([#603])
|
||||||
|
* Updated [`tracing-subscriber`](https://github.com/tokio-rs/tracing) from 0.3.16 to 0.3.17 ([#604])
|
||||||
|
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.27.0 to 1.28.0 ([#605])
|
||||||
|
* Updated [`tracing`](https://github.com/tokio-rs/tracing) from 0.1.37 to 0.1.38 ([#607])
|
||||||
|
* Updated [`vergen`](https://github.com/rustyhorde/vergen) from 8.1.1 to 8.1.3 ([#608])
|
||||||
|
* Downgrade yanked [`tracing`](https://github.com/tokio-rs/tracing) 0.1.38 to 0.1.37 ([#611])
|
||||||
|
* Updated [`reqwest`](https://github.com/seanmonstar/reqwest) from 0.11.16 to 0.11.17 ([#609])
|
||||||
|
* Updated [`anyhow`](https://github.com/dtolnay/anyhow) from 1.0.70 to 1.0.71 ([#610])
|
||||||
|
|
||||||
|
[#599]: https://github.com/vbrandl/hoc/pull/599
|
||||||
|
[#602]: https://github.com/vbrandl/hoc/pull/602
|
||||||
|
[#603]: https://github.com/vbrandl/hoc/pull/603
|
||||||
|
[#604]: https://github.com/vbrandl/hoc/pull/604
|
||||||
|
[#605]: https://github.com/vbrandl/hoc/pull/605
|
||||||
|
[#607]: https://github.com/vbrandl/hoc/pull/607
|
||||||
|
[#608]: https://github.com/vbrandl/hoc/pull/608
|
||||||
|
[#611]: https://github.com/vbrandl/hoc/pull/611
|
||||||
|
[#609]: https://github.com/vbrandl/hoc/pull/609
|
||||||
|
[#610]: https://github.com/vbrandl/hoc/pull/610
|
||||||
|
|
||||||
|
[SEC#11]: https://github.com/vbrandl/hoc/security/dependabot/11
|
||||||
|
|
||||||
|
|
||||||
|
## [0.34.0] 2023-04-13
|
||||||
|
|
||||||
|
* 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])
|
||||||
|
* Updated [`tempfile`](https://github.com/Stebalien/tempfile) from 3.4.0 to 3.5.0 ([#590])
|
||||||
|
* Updated [`tracing-bunyan-formatter`](https://github.com/LukeMathWalker/tracing-bunyan-formatter) from 0.3.6 to 0.3.7 ([#593])
|
||||||
|
* Updated [`serde`](https://github.com/serde-rs/serde) from 1.0.158 to 1.0.160 ([#594])
|
||||||
|
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.94 to 1.0.96 ([#595])
|
||||||
|
* Updated [`openssl`](https://github.com/sfackler/rust-openssl) from 0.10.40 to 0.10.50, fixes [SEC#6], [SEC#7], and [SEC#8] ([#596])
|
||||||
|
|
||||||
|
[#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
|
||||||
|
[#590]: https://github.com/vbrandl/hoc/pull/590
|
||||||
|
[#593]: https://github.com/vbrandl/hoc/pull/593
|
||||||
|
[#594]: https://github.com/vbrandl/hoc/pull/594
|
||||||
|
[#595]: https://github.com/vbrandl/hoc/pull/595
|
||||||
|
[#596]: https://github.com/vbrandl/hoc/pull/596
|
||||||
|
|
||||||
|
[SEC#6]: https://github.com/vbrandl/hoc/security/dependabot/6
|
||||||
|
[SEC#7]: https://github.com/vbrandl/hoc/security/dependabot/7
|
||||||
|
[SEC#8]: https://github.com/vbrandl/hoc/security/dependabot/8
|
||||||
|
|
||||||
|
|
||||||
|
## [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
|
## [0.29.0] 2023-01-07
|
||||||
|
|
||||||
### Dependency Updates
|
### Dependency Updates
|
||||||
@ -88,4 +236,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
[#502]: https://github.com/vbrandl/hoc/pull/502
|
[#502]: https://github.com/vbrandl/hoc/pull/502
|
||||||
[#503]: https://github.com/vbrandl/hoc/pull/503
|
[#503]: https://github.com/vbrandl/hoc/pull/503
|
||||||
[#504]: https://github.com/vbrandl/hoc/pull/504
|
[#504]: https://github.com/vbrandl/hoc/pull/504
|
||||||
[#508]: https://github.com/vbrandl/hoc/pull/508
|
[#508]: https://github.com/vbrandl/hoc/pull/508
|
1831
Cargo.lock
generated
1831
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
45
Cargo.toml
45
Cargo.toml
@ -1,9 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "hoc"
|
name = "hoc"
|
||||||
version = "0.29.0"
|
version = "0.35.0"
|
||||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
build = "build.rs"
|
build = "src/build.rs"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
@ -13,35 +13,36 @@ 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.1.0"
|
badgers = "1.2.0"
|
||||||
bytes = "1.3.0"
|
bytes = "1.4.0"
|
||||||
config = { version = "0.13.3", features = ["toml"] }
|
config = { version = "0.13.3", features = ["toml"] }
|
||||||
dotenvy = "0.15.6"
|
dotenvy = "0.15.7"
|
||||||
futures = "0.3.25"
|
futures = "0.3.27"
|
||||||
git2 = "0.15.0"
|
git2 = "0.17.2"
|
||||||
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.18"
|
||||||
serde = "1.0.152"
|
serde = "1.0.164"
|
||||||
serde_derive = "1.0.137"
|
serde_derive = "1.0.137"
|
||||||
serde_json = "1.0.91"
|
serde_json = "1.0.94"
|
||||||
tracing = "0.1.37"
|
tracing = "0.1.37"
|
||||||
tracing-actix-web = "0.7.1"
|
tracing-actix-web = "0.7.5"
|
||||||
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.17", features = ["registry", "env-filter"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
ructe = { version = "0.15.0", features = ["mime03"] }
|
anyhow = "1.0.71"
|
||||||
vergen = { version = "7.5.0", default-features = false, features = ["git"] }
|
ructe = { version = "0.16.1", features = ["mime03"] }
|
||||||
|
vergen = { version = "8.2.1", default-features = false, features = ["git", "gitoxide"] }
|
||||||
|
|
||||||
[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.6.0"
|
||||||
tokio = "1.24.1"
|
tokio = "1.28.2"
|
||||||
|
@ -10,7 +10,7 @@ RUN echo 'fn main() { println!("Hello, world!"); }' >> src/main.rs
|
|||||||
COPY ./Cargo.lock ./Cargo.lock
|
COPY ./Cargo.lock ./Cargo.lock
|
||||||
COPY ./Cargo.toml ./Cargo.toml
|
COPY ./Cargo.toml ./Cargo.toml
|
||||||
# HACK: remove build-dependencies so we have at least some caching
|
# HACK: remove build-dependencies so we have at least some caching
|
||||||
RUN head -n $(($(grep -n "\[build-dependencies\]" Cargo.toml | cut -f1 -d:) - 1)) Cargo.toml | sed '/build.rs/d' > \
|
RUN head -n $(($(grep -n "\[build-dependencies\]" Cargo.toml | cut -f1 -d:) - 1)) Cargo.toml | sed '/src\/build.rs/d' > \
|
||||||
Cargo.toml2 && rm Cargo.toml && mv Cargo.toml2 Cargo.toml
|
Cargo.toml2 && rm Cargo.toml && mv Cargo.toml2 Cargo.toml
|
||||||
# build to cache dependencies
|
# build to cache dependencies
|
||||||
RUN cargo build --release
|
RUN cargo build --release
|
||||||
@ -24,7 +24,6 @@ COPY ./.git ./.git
|
|||||||
# copy source code
|
# copy source code
|
||||||
COPY ./static ./static
|
COPY ./static ./static
|
||||||
COPY ./templates ./templates
|
COPY ./templates ./templates
|
||||||
COPY ./build.rs ./build.rs
|
|
||||||
COPY ./src ./src
|
COPY ./src ./src
|
||||||
# build source code
|
# build source code
|
||||||
RUN cargo build --release
|
RUN cargo build --release
|
||||||
|
15
build.rs
15
build.rs
@ -1,15 +0,0 @@
|
|||||||
extern crate ructe;
|
|
||||||
extern crate vergen;
|
|
||||||
|
|
||||||
use ructe::{Ructe, RucteError};
|
|
||||||
use vergen::{vergen, Config, ShaKind};
|
|
||||||
|
|
||||||
fn main() -> Result<(), RucteError> {
|
|
||||||
let mut config = Config::default();
|
|
||||||
*config.git_mut().sha_kind_mut() = ShaKind::Short;
|
|
||||||
vergen(config).expect("Unable to generate static repo info");
|
|
||||||
let mut ructe = Ructe::from_env()?;
|
|
||||||
let mut statics = ructe.statics()?;
|
|
||||||
statics.add_files("static")?;
|
|
||||||
ructe.compile_templates("templates")
|
|
||||||
}
|
|
12
src/build.rs
Normal file
12
src/build.rs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
use anyhow::Result;
|
||||||
|
use ructe::Ructe;
|
||||||
|
use vergen::EmitBuilder;
|
||||||
|
|
||||||
|
fn main() -> Result<()> {
|
||||||
|
EmitBuilder::builder().git_sha(true).emit()?;
|
||||||
|
|
||||||
|
let mut ructe = Ructe::from_env()?;
|
||||||
|
let mut statics = ructe.statics()?;
|
||||||
|
statics.add_files("static")?;
|
||||||
|
Ok(ructe.compile_templates("templates")?)
|
||||||
|
}
|
13
src/cache.rs
13
src/cache.rs
@ -36,10 +36,10 @@ impl<'a> CacheState<'a> {
|
|||||||
trace!("Reading cache");
|
trace!("Reading cache");
|
||||||
if path.as_ref().exists() {
|
if path.as_ref().exists() {
|
||||||
let cache: Cache = serde_json::from_reader(BufReader::new(File::open(path)?))?;
|
let cache: Cache = serde_json::from_reader(BufReader::new(File::open(path)?))?;
|
||||||
Ok(cache
|
Ok(cache.entries.get(branch).map_or_else(
|
||||||
.entries
|
// TODO: get rid of clone
|
||||||
.get(branch)
|
|| CacheState::NoneForBranch(cache.clone()),
|
||||||
.map(|c| {
|
|c| {
|
||||||
if c.head == head {
|
if c.head == head {
|
||||||
trace!("Cache is up to date");
|
trace!("Cache is up to date");
|
||||||
CacheState::Current {
|
CacheState::Current {
|
||||||
@ -56,9 +56,8 @@ impl<'a> CacheState<'a> {
|
|||||||
cache: cache.clone(),
|
cache: cache.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
// TODO: get rid of clone
|
))
|
||||||
.unwrap_or_else(|| CacheState::NoneForBranch(cache.clone())))
|
|
||||||
} else {
|
} else {
|
||||||
Ok(CacheState::No)
|
Ok(CacheState::No)
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,12 @@ pub struct Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
|
/// Load the configuration from file and environment.
|
||||||
|
///
|
||||||
|
/// # Errors
|
||||||
|
///
|
||||||
|
/// * File cannot be read or parsed
|
||||||
|
/// * Environment variables cannot be parsed
|
||||||
pub fn load() -> Result<Self, ConfigError> {
|
pub fn load() -> Result<Self, ConfigError> {
|
||||||
Config::builder()
|
Config::builder()
|
||||||
.add_source(File::with_name("hoc.toml").required(false))
|
.add_source(File::with_name("hoc.toml").required(false))
|
||||||
|
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)
|
||||||
|
84
src/lib.rs
84
src/lib.rs
@ -22,7 +22,7 @@ use crate::{
|
|||||||
cache::CacheState,
|
cache::CacheState,
|
||||||
config::Settings,
|
config::Settings,
|
||||||
error::{Error, Result},
|
error::{Error, Result},
|
||||||
service::{Bitbucket, FormService, GitHub, Gitlab, Service, Sourcehut},
|
service::{Bitbucket, FormValue, GitHub, Gitlab, Service, Sourcehut},
|
||||||
statics::{CLIENT, VERSION_INFO},
|
statics::{CLIENT, VERSION_INFO},
|
||||||
template::{RepoGeneratorInfo, RepoInfo},
|
template::{RepoGeneratorInfo, RepoInfo},
|
||||||
};
|
};
|
||||||
@ -53,7 +53,7 @@ include!(concat!(env!("OUT_DIR"), "/templates.rs"));
|
|||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
struct GeneratorForm<'a> {
|
struct GeneratorForm<'a> {
|
||||||
service: FormService,
|
service: FormValue,
|
||||||
user: Cow<'a, str>,
|
user: Cow<'a, str>,
|
||||||
repo: Cow<'a, str>,
|
repo: Cow<'a, str>,
|
||||||
branch: Option<Cow<'a, str>>,
|
branch: Option<Cow<'a, str>>,
|
||||||
@ -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...
|
||||||
@ -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,8 +214,8 @@ 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(())
|
||||||
@ -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,12 +304,12 @@ 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();
|
||||||
let mapper = move |r| match r {
|
let mapper = move |r| match r {
|
||||||
HocResult::NotFound => p404(rc_clone),
|
HocResult::NotFound => p404(&rc_clone),
|
||||||
HocResult::Hoc {
|
HocResult::Hoc {
|
||||||
hoc, head, commits, ..
|
hoc, head, commits, ..
|
||||||
} => Ok(HttpResponse::Ok().json(JsonResponse {
|
} => Ok(HttpResponse::Ok().json(JsonResponse {
|
||||||
@ -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,13 +379,14 @@ 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 {
|
||||||
HocResult::NotFound => p404(rc_clone),
|
HocResult::NotFound => p404(&rc_clone),
|
||||||
HocResult::Hoc {
|
HocResult::Hoc {
|
||||||
hoc,
|
hoc,
|
||||||
commits,
|
commits,
|
||||||
@ -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))
|
||||||
@ -414,17 +423,19 @@ async fn overview<T: Service>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/health_check")]
|
#[get("/health_check")]
|
||||||
|
#[allow(clippy::unused_async)]
|
||||||
async fn health_check() -> HttpResponse {
|
async fn health_check() -> HttpResponse {
|
||||||
HttpResponse::Ok().finish()
|
HttpResponse::Ok().finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
|
#[allow(clippy::unused_async)]
|
||||||
async fn index(
|
async fn index(
|
||||||
state: web::Data<State>,
|
state: web::Data<State>,
|
||||||
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),
|
||||||
@ -434,6 +445,7 @@ async fn index(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/generate")]
|
#[post("/generate")]
|
||||||
|
#[allow(clippy::unused_async)]
|
||||||
async fn generate(
|
async fn generate(
|
||||||
params: web::Form<GeneratorForm<'_>>,
|
params: web::Form<GeneratorForm<'_>>,
|
||||||
state: web::Data<State>,
|
state: web::Data<State>,
|
||||||
@ -450,7 +462,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),
|
||||||
@ -461,20 +473,22 @@ async fn generate(
|
|||||||
Ok(HttpResponse::Ok().content_type("text/html").body(buf))
|
Ok(HttpResponse::Ok().content_type("text/html").body(buf))
|
||||||
}
|
}
|
||||||
|
|
||||||
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))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::unused_async)]
|
||||||
async fn async_p404(repo_count: web::Data<AtomicUsize>) -> Result<HttpResponse> {
|
async fn async_p404(repo_count: web::Data<AtomicUsize>) -> Result<HttpResponse> {
|
||||||
p404(repo_count)
|
p404(&repo_count)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A duration to add to current time for a far expires header.
|
/// A duration to add to current time for a far expires header.
|
||||||
static FAR: Duration = Duration::from_secs(180 * 24 * 60 * 60);
|
static FAR: Duration = Duration::from_secs(180 * 24 * 60 * 60);
|
||||||
|
|
||||||
#[get("/static/{filename}")]
|
#[get("/static/{filename}")]
|
||||||
|
#[allow(clippy::unused_async)]
|
||||||
async fn static_file(
|
async fn static_file(
|
||||||
path: web::Path<String>,
|
path: web::Path<String>,
|
||||||
repo_count: web::Data<AtomicUsize>,
|
repo_count: web::Data<AtomicUsize>,
|
||||||
@ -487,11 +501,11 @@ async fn static_file(
|
|||||||
.content_type(data.mime.clone())
|
.content_type(data.mime.clone())
|
||||||
.body(data.content)
|
.body(data.content)
|
||||||
})
|
})
|
||||||
.map(Result::Ok)
|
.map_or_else(|| p404(&repo_count), Result::Ok)
|
||||||
.unwrap_or_else(|| p404(repo_count))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/favicon.ico")]
|
#[get("/favicon.ico")]
|
||||||
|
#[allow(clippy::unused_async)]
|
||||||
async fn favicon32() -> HttpResponse {
|
async fn favicon32() -> HttpResponse {
|
||||||
let data = &template_statics::favicon32_png;
|
let data = &template_statics::favicon32_png;
|
||||||
HttpResponse::Ok()
|
HttpResponse::Ok()
|
||||||
@ -499,6 +513,7 @@ async fn favicon32() -> HttpResponse {
|
|||||||
.body(data.content)
|
.body(data.content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::unused_async)]
|
||||||
async fn start_server(listener: TcpListener, settings: Settings) -> std::io::Result<Server> {
|
async fn start_server(listener: TcpListener, settings: Settings) -> std::io::Result<Server> {
|
||||||
let workers = settings.workers;
|
let workers = settings.workers;
|
||||||
let repo_count =
|
let repo_count =
|
||||||
@ -527,6 +542,11 @@ async fn start_server(listener: TcpListener, settings: Settings) -> std::io::Res
|
|||||||
.run())
|
.run())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Start the server.
|
||||||
|
///
|
||||||
|
/// # Errors
|
||||||
|
///
|
||||||
|
/// * server cannot bind to `listener`
|
||||||
pub async fn run(listener: TcpListener, settings: Settings) -> std::io::Result<Server> {
|
pub async fn run(listener: TcpListener, settings: Settings) -> std::io::Result<Server> {
|
||||||
let span = info_span!("hoc", version = env!("CARGO_PKG_VERSION"));
|
let span = info_span!("hoc", version = env!("CARGO_PKG_VERSION"));
|
||||||
let _ = span.enter();
|
let _ = span.enter();
|
||||||
|
@ -29,7 +29,7 @@ pub(crate) trait Service: Sized + 'static {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Clone, Copy)]
|
#[derive(Deserialize, Serialize, Clone, Copy)]
|
||||||
pub enum FormService {
|
pub enum FormValue {
|
||||||
#[serde(rename = "github")]
|
#[serde(rename = "github")]
|
||||||
GitHub,
|
GitHub,
|
||||||
#[serde(rename = "gitlab")]
|
#[serde(rename = "gitlab")]
|
||||||
@ -40,22 +40,22 @@ pub enum FormService {
|
|||||||
Sourcehut,
|
Sourcehut,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FormService {
|
impl FormValue {
|
||||||
pub(crate) fn url(&self) -> &str {
|
pub(crate) fn url(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
FormService::GitHub => "github.com",
|
FormValue::GitHub => "github.com",
|
||||||
FormService::Gitlab => "gitlab.com",
|
FormValue::Gitlab => "gitlab.com",
|
||||||
FormService::Bitbucket => "bitbucket.org",
|
FormValue::Bitbucket => "bitbucket.org",
|
||||||
FormService::Sourcehut => "git.sr.ht",
|
FormValue::Sourcehut => "git.sr.ht",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn service(&self) -> &str {
|
pub(crate) fn service(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
FormService::GitHub => "github",
|
FormValue::GitHub => "github",
|
||||||
FormService::Gitlab => "gitlab",
|
FormValue::Gitlab => "gitlab",
|
||||||
FormService::Bitbucket => "bitbucket",
|
FormValue::Bitbucket => "bitbucket",
|
||||||
FormService::Sourcehut => "sourcehut",
|
FormValue::Sourcehut => "sourcehut",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
#[derive(Clone, Copy)]
|
||||||
pub struct VersionInfo<'a> {
|
pub struct VersionInfo<'a> {
|
||||||
pub commit: &'a str,
|
pub commit: &'a str,
|
||||||
pub version: &'a str,
|
pub version: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) const VERSION_INFO: VersionInfo = VersionInfo {
|
pub(crate) const VERSION_INFO: VersionInfo = VersionInfo {
|
||||||
commit: env!("VERGEN_GIT_SHA_SHORT"),
|
commit: env!("VERGEN_GIT_SHA"),
|
||||||
version: env!("CARGO_PKG_VERSION"),
|
version: env!("CARGO_PKG_VERSION"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use crate::service::FormService;
|
use crate::service::FormValue;
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
pub struct RepoInfo<'a> {
|
pub struct RepoInfo<'a> {
|
||||||
pub commit_url: &'a str,
|
pub commit_url: &'a str,
|
||||||
pub commits: u64,
|
pub commits: u64,
|
||||||
@ -13,7 +14,7 @@ pub struct RepoInfo<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct RepoGeneratorInfo<'a> {
|
pub struct RepoGeneratorInfo<'a> {
|
||||||
pub service: FormService,
|
pub service: FormValue,
|
||||||
pub user: &'a str,
|
pub user: &'a str,
|
||||||
pub repo: &'a str,
|
pub repo: &'a str,
|
||||||
pub branch: &'a str,
|
pub branch: &'a str,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@use super::statics::*;
|
@use super::statics::tacit_css_min_css;
|
||||||
@use crate::statics::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(title: &str, header: &str, content: Content, version_info: VersionInfo, repo_count: usize)
|
@(title: &str, header: &str, content: Content, version_info: VersionInfo, repo_count: usize)
|
||||||
|
@ -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: &str)
|
||||||
|
|
||||||
@: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>
|
||||||
|
@ -38,6 +38,8 @@ pub async fn spawn_app() -> TestApp {
|
|||||||
.await
|
.await
|
||||||
.expect("Failed to bind address");
|
.expect("Failed to bind address");
|
||||||
|
|
||||||
|
#[allow(clippy::let_underscore_future)]
|
||||||
|
// don't await so the test server runs in the background
|
||||||
let _ = tokio::spawn(server);
|
let _ = tokio::spawn(server);
|
||||||
|
|
||||||
TestApp {
|
TestApp {
|
||||||
|
Reference in New Issue
Block a user