Compare commits
No commits in common. "master" and "release/0.26.0" have entirely different histories.
master
...
release/0.
24
.github/dependabot.yml
vendored
24
.github/dependabot.yml
vendored
@ -10,27 +10,3 @@ 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
|
|
||||||
|
|
||||||
- package-ecosystem: docker
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: daily
|
|
||||||
time: "04:00"
|
|
||||||
open-pull-requests-limit: 10
|
|
||||||
assignees:
|
|
||||||
- vbrandl
|
|
||||||
labels:
|
|
||||||
- dependencies
|
|
||||||
- dependabot
|
|
||||||
|
4
.github/workflows/audit.yml
vendored
4
.github/workflows/audit.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
|||||||
security_audit:
|
security_audit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: rustsec/audit-check@v1
|
- uses: actions-rs/audit-check@v1
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
26
.github/workflows/dependabot-changelog.yml
vendored
26
.github/workflows/dependabot-changelog.yml
vendored
@ -1,26 +0,0 @@
|
|||||||
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@v4
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.ACTION_TOKEN }}
|
|
||||||
- uses: dangoslen/dependabot-changelog-helper@v3
|
|
||||||
with:
|
|
||||||
activationLabel: 'dependabot'
|
|
||||||
- uses: stefanzweifel/git-auto-commit-action@v5
|
|
||||||
with:
|
|
||||||
commit_message: "Update Changelog"
|
|
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@ -33,7 +33,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install stable toolchain
|
- name: Install stable toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
@ -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@v4
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo/registry
|
~/.cargo/registry
|
||||||
@ -71,7 +71,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Releasing assets
|
- name: Releasing assets
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
files: |
|
files: |
|
||||||
target/${{ matrix.target }}/release/hoc-${{ matrix.artifact_prefix }}.tar.gz
|
target/${{ matrix.target }}/release/hoc-${{ matrix.artifact_prefix }}.tar.gz
|
||||||
@ -84,7 +84,7 @@ jobs:
|
|||||||
needs: [tests]
|
needs: [tests]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: taiki-e/create-gh-release-action@v1
|
- uses: taiki-e/create-gh-release-action@v1
|
||||||
with:
|
with:
|
||||||
changelog: CHANGELOG.md
|
changelog: CHANGELOG.md
|
||||||
|
47
.github/workflows/rust.yml
vendored
47
.github/workflows/rust.yml
vendored
@ -13,27 +13,39 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install stable toolchain
|
- name: Install stable toolchain
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
profile: minimal
|
||||||
|
override: true
|
||||||
|
components: rustfmt
|
||||||
|
|
||||||
- name: Check Formatting
|
- name: Check Formatting
|
||||||
run: cargo fmt --all -- --check
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: --all -- --check
|
||||||
|
|
||||||
clippy:
|
clippy:
|
||||||
name: Clippy
|
name: Clippy
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install stable toolchain
|
- name: Install stable toolchain
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: actions-rs/toolchain@v1
|
||||||
|
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@v4
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo/registry
|
~/.cargo/registry
|
||||||
@ -42,9 +54,10 @@ jobs:
|
|||||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
- name: Clippy Linting
|
- name: Clippy Linting
|
||||||
run: cargo clippy --all-features -- -Dclippy::all -Dclippy::pedantic
|
uses: actions-rs/cargo@v1
|
||||||
- name: Clippy Test Linting
|
with:
|
||||||
run: cargo clippy --tests -- -Dclippy::all -Dclippy::pedantic
|
command: clippy
|
||||||
|
args: -- -D warnings
|
||||||
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@ -58,13 +71,17 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install stable toolchain
|
- name: Install stable toolchain
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: actions-rs/toolchain@v1
|
||||||
|
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@v4
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo/registry
|
~/.cargo/registry
|
||||||
@ -73,4 +90,6 @@ jobs:
|
|||||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: cargo test
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
257
CHANGELOG.md
257
CHANGELOG.md
@ -5,263 +5,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Dependencies
|
|
||||||
- Bump `serde` from 1.0.192 to 1.0.204 ([#704](https://github.com/vbrandl/hoc/pull/704), [#719](https://github.com/vbrandl/hoc/pull/719), [#726](https://github.com/vbrandl/hoc/pull/726), [#736](https://github.com/vbrandl/hoc/pull/736), [#761](https://github.com/vbrandl/hoc/pull/761), [#766](https://github.com/vbrandl/hoc/pull/766), [#767](https://github.com/vbrandl/hoc/pull/767), [#771](https://github.com/vbrandl/hoc/pull/771), [#775](https://github.com/vbrandl/hoc/pull/775), [#787](https://github.com/vbrandl/hoc/pull/787))
|
|
||||||
- Bump `config` from 0.13.3 to 0.14.0 ([#705](https://github.com/vbrandl/hoc/pull/705), [#729](https://github.com/vbrandl/hoc/pull/729))
|
|
||||||
- Bump `openssl` from 0.10.55 to 0.10.60 ([#706](https://github.com/vbrandl/hoc/pull/706))
|
|
||||||
- Bump `tokio` from 1.34.0 to 1.38.0 ([#707](https://github.com/vbrandl/hoc/pull/707), [#709](https://github.com/vbrandl/hoc/pull/709), [#732](https://github.com/vbrandl/hoc/pull/732), [#756](https://github.com/vbrandl/hoc/pull/756), [#776](https://github.com/vbrandl/hoc/pull/776))
|
|
||||||
- Bump `reqwest` from 0.11.22 to 0.12.5 ([#708](https://github.com/vbrandl/hoc/pull/708), [#728](https://github.com/vbrandl/hoc/pull/728), [#741](https://github.com/vbrandl/hoc/pull/741), [#745](https://github.com/vbrandl/hoc/pull/745), [#749](https://github.com/vbrandl/hoc/pull/749), [#750](https://github.com/vbrandl/hoc/pull/750), [#754](https://github.com/vbrandl/hoc/pull/754), [#758](https://github.com/vbrandl/hoc/pull/758), [#765](https://github.com/vbrandl/hoc/pull/765), [#781](https://github.com/vbrandl/hoc/pull/781))
|
|
||||||
- Bump `anyhow` from 1.0.75 to 1.0.86 ([#710](https://github.com/vbrandl/hoc/pull/710), [#714](https://github.com/vbrandl/hoc/pull/714), [#720](https://github.com/vbrandl/hoc/pull/720), [#737](https://github.com/vbrandl/hoc/pull/737), [#744](https://github.com/vbrandl/hoc/pull/744), [#759](https://github.com/vbrandl/hoc/pull/759), [#768](https://github.com/vbrandl/hoc/pull/768), [#772](https://github.com/vbrandl/hoc/pull/772))
|
|
||||||
- Bump `futures` from 0.3.29 to 0.3.30 ([#711](https://github.com/vbrandl/hoc/pull/711))
|
|
||||||
- Bump `awc` from 3.2.0 to 3.5.0 ([#712](https://github.com/vbrandl/hoc/pull/712), [#731](https://github.com/vbrandl/hoc/pull/731), [#774](https://github.com/vbrandl/hoc/pull/774))
|
|
||||||
- Bump `actix-web` from 4.4.0 to 4.8.0 ([#713](https://github.com/vbrandl/hoc/pull/713), [#739](https://github.com/vbrandl/hoc/pull/739), [#773](https://github.com/vbrandl/hoc/pull/773), [#782](https://github.com/vbrandl/hoc/pull/782))
|
|
||||||
- Bump `tempfile` from 3.8.1 to 3.10.1 ([#715](https://github.com/vbrandl/hoc/pull/715), [#752](https://github.com/vbrandl/hoc/pull/752))
|
|
||||||
- Bump `serde_json` from 1.0.108 to 1.0.120 ([#717](https://github.com/vbrandl/hoc/pull/717), [#722](https://github.com/vbrandl/hoc/pull/722), [#727](https://github.com/vbrandl/hoc/pull/727), [#738](https://github.com/vbrandl/hoc/pull/738), [#760](https://github.com/vbrandl/hoc/pull/760), [#770](https://github.com/vbrandl/hoc/pull/770), [#784](https://github.com/vbrandl/hoc/pull/784), [#786](https://github.com/vbrandl/hoc/pull/786))
|
|
||||||
- Bump `vergen` from 8.2.6 to 8.3.1 ([#721](https://github.com/vbrandl/hoc/pull/721), [#730](https://github.com/vbrandl/hoc/pull/730))
|
|
||||||
- Bump `actions/cache` from 3 to 4 ([#724](https://github.com/vbrandl/hoc/pull/724))
|
|
||||||
- Bump `h2` from 0.3.20 to 0.3.26 ([#725](https://github.com/vbrandl/hoc/pull/725), [#757](https://github.com/vbrandl/hoc/pull/757))
|
|
||||||
- Bump `git2` from 0.18.1 to 0.18.3 ([#734](https://github.com/vbrandl/hoc/pull/734), [#748](https://github.com/vbrandl/hoc/pull/748))
|
|
||||||
- Bump `tracing-actix-web` from 0.7.9 to 0.7.11 ([#742](https://github.com/vbrandl/hoc/pull/742), [#777](https://github.com/vbrandl/hoc/pull/777))
|
|
||||||
- Bump `mio` from 0.8.9 to 0.8.11 ([#740](https://github.com/vbrandl/hoc/pull/740))
|
|
||||||
- Bump `softprops/action-gh-release` from 1 to 2 ([#743](https://github.com/vbrandl/hoc/pull/743))
|
|
||||||
- Bump `bytes` from 1.5.0 to 1.6.0 ([#751](https://github.com/vbrandl/hoc/pull/751))
|
|
||||||
- Bump `actix-rt` from 2.9.0 to 2.10.0 ([#779](https://github.com/vbrandl/hoc/pull/779))
|
|
||||||
- Bump `lazy_static` from 1.4.0 to 1.5.0 ([#783](https://github.com/vbrandl/hoc/pull/783))
|
|
||||||
|
|
||||||
## [0.36.0] 2023-11-17
|
|
||||||
### Dependencies
|
|
||||||
- Bump `serde` from 1.0.160 to 1.0.192 (#613, #617, #627, #636, #639, #640, #645, [#648](https://github.com/vbrandl/hoc/pull/648), [#650](https://github.com/vbrandl/hoc/pull/650), [#652](https://github.com/vbrandl/hoc/pull/652), [#653](https://github.com/vbrandl/hoc/pull/653), [#654](https://github.com/vbrandl/hoc/pull/654), [#655](https://github.com/vbrandl/hoc/pull/655), [#657](https://github.com/vbrandl/hoc/pull/657), [#669](https://github.com/vbrandl/hoc/pull/669), [#687](https://github.com/vbrandl/hoc/pull/687), [#692](https://github.com/vbrandl/hoc/pull/692), [#698](https://github.com/vbrandl/hoc/pull/698))
|
|
||||||
- Bump `actions/cache` from 2 to 3 (#616)
|
|
||||||
- Bump `tokio` from 1.28.0 to 1.34.0 (#618, #625, #633, #634, [#659](https://github.com/vbrandl/hoc/pull/659), [#660](https://github.com/vbrandl/hoc/pull/660), [#665](https://github.com/vbrandl/hoc/pull/665), [#686](https://github.com/vbrandl/hoc/pull/686), [#699](https://github.com/vbrandl/hoc/pull/699))
|
|
||||||
- Bump `reqwest` from 0.11.17 to 0.11.22 (#619, [#672](https://github.com/vbrandl/hoc/pull/672), [#683](https://github.com/vbrandl/hoc/pull/683), [#684](https://github.com/vbrandl/hoc/pull/684))
|
|
||||||
- Bump `vergen` from 8.1.3 to 8.2.6 (#621, #622, #635, #638, [#679](https://github.com/vbrandl/hoc/pull/679), [#697](https://github.com/vbrandl/hoc/pull/697))
|
|
||||||
- Bump `tracing-actix-web` from 0.7.4 to 0.7.9 (#623, [#656](https://github.com/vbrandl/hoc/pull/656), [#682](https://github.com/vbrandl/hoc/pull/682), [#690](https://github.com/vbrandl/hoc/pull/690), [#701](https://github.com/vbrandl/hoc/pull/701))
|
|
||||||
- Bump `git2` from 0.17.1 to 0.18.1 (#624, [#674](https://github.com/vbrandl/hoc/pull/674), [#681](https://github.com/vbrandl/hoc/pull/681))
|
|
||||||
- Bump `tempfile` from 3.5.0 to 3.8.1 (#626, [#646](https://github.com/vbrandl/hoc/pull/646), [#658](https://github.com/vbrandl/hoc/pull/658), [#667](https://github.com/vbrandl/hoc/pull/667), [#695](https://github.com/vbrandl/hoc/pull/695))
|
|
||||||
- Bump `serde_json` from 1.0.96 to 1.0.108 (#630, #632, #637, #641, #644, [#649](https://github.com/vbrandl/hoc/pull/649), [#663](https://github.com/vbrandl/hoc/pull/663), [#678](https://github.com/vbrandl/hoc/pull/678), [#680](https://github.com/vbrandl/hoc/pull/680), [#696](https://github.com/vbrandl/hoc/pull/696))
|
|
||||||
- Bump `openssl` from 0.10.50 to 0.10.55 (#631)
|
|
||||||
- Bump `tracing-bunyan-formatter` from 0.3.7 to 0.3.9 (#642, [#661](https://github.com/vbrandl/hoc/pull/661))
|
|
||||||
- Bump `anyhow` from 1.0.71 to 1.0.75 (#643, [#662](https://github.com/vbrandl/hoc/pull/662), [#664](https://github.com/vbrandl/hoc/pull/664))
|
|
||||||
- Bump `ructe` from 0.16.1 to 0.17.0 ([#647](https://github.com/vbrandl/hoc/pull/647))
|
|
||||||
- Bump `actix-rt` from 2.8.0 to 2.9.0 ([#670](https://github.com/vbrandl/hoc/pull/670))
|
|
||||||
- Bump `actix-web` from 4.3.1 to 4.4.0 ([#673](https://github.com/vbrandl/hoc/pull/673))
|
|
||||||
- Bump `awc` from 3.1.1 to 3.2.0 ([#675](https://github.com/vbrandl/hoc/pull/675))
|
|
||||||
- Bump `actions/checkout` from 3 to 4 ([#676](https://github.com/vbrandl/hoc/pull/676))
|
|
||||||
- Bump `bytes` from 1.4.0 to 1.5.0 ([#677](https://github.com/vbrandl/hoc/pull/677))
|
|
||||||
- Bump `stefanzweifel/git-auto-commit-action` from 4 to 5 ([#685](https://github.com/vbrandl/hoc/pull/685))
|
|
||||||
- Bump `tracing` from 0.1.37 to 0.1.40 ([#688](https://github.com/vbrandl/hoc/pull/688), [#689](https://github.com/vbrandl/hoc/pull/689))
|
|
||||||
- Bump `tracing-log` from 0.1.3 to 0.2.0 ([#691](https://github.com/vbrandl/hoc/pull/691), [#693](https://github.com/vbrandl/hoc/pull/693))
|
|
||||||
- Bump `futures` from 0.3.28 to 0.3.29 ([#694](https://github.com/vbrandl/hoc/pull/694))
|
|
||||||
- Bump `tracing-subscriber` from 0.3.17 to 0.3.18 ([#702](https://github.com/vbrandl/hoc/pull/702))
|
|
||||||
|
|
||||||
|
|
||||||
## [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
|
|
||||||
|
|
||||||
### 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
|
||||||
|
2317
Cargo.lock
generated
2317
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
55
Cargo.toml
55
Cargo.toml
@ -1,9 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "hoc"
|
name = "hoc"
|
||||||
version = "0.36.0"
|
version = "0.26.0"
|
||||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||||
edition = "2021"
|
edition = "2018"
|
||||||
build = "src/build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
@ -13,36 +13,35 @@ path = "src/main.rs"
|
|||||||
name = "hoc"
|
name = "hoc"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-rt = "2.10.0"
|
actix-rt = "2.7.0"
|
||||||
actix-web = "4.8.0"
|
actix-web = "4.2.1"
|
||||||
badgers = "1.2.0"
|
badgers = "1.0.0"
|
||||||
bytes = "1.6.0"
|
bytes = "1.2.1"
|
||||||
config = { version = "0.14.0", features = ["toml"], default-features = false }
|
config = { version = "0.13.2", features = ["toml"] }
|
||||||
dotenvy = "0.15.7"
|
dotenvy = "0.15.6"
|
||||||
futures = "0.3.30"
|
futures = "0.3.24"
|
||||||
git2 = "0.19.0"
|
git2 = "0.15.0"
|
||||||
lazy_static = "1.5.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.12.5"
|
reqwest = "0.11.12"
|
||||||
serde = "1.0.204"
|
serde = "1.0.145"
|
||||||
serde_derive = "1.0.204"
|
serde_derive = "1.0.137"
|
||||||
serde_json = "1.0.120"
|
serde_json = "1.0.86"
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.37"
|
||||||
tracing-actix-web = "0.7.11"
|
tracing-actix-web = "0.6.1"
|
||||||
tracing-bunyan-formatter = "0.3.9"
|
tracing-bunyan-formatter = "0.3.4"
|
||||||
tracing-futures = "0.2.5"
|
tracing-futures = "0.2.5"
|
||||||
tracing-log = "0.2.0"
|
tracing-log = "0.1.3"
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["registry", "env-filter"] }
|
tracing-subscriber = { version = "0.3.16", features = ["registry", "env-filter"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
anyhow = "1.0.86"
|
ructe = { version = "0.15.0", features = ["mime03"] }
|
||||||
ructe = { version = "0.17.2", features = ["mime03"] }
|
vergen = { version = "7.3.1", default-features = false, features = ["git"] }
|
||||||
vergen = { version = "8.3.1", default-features = false, features = ["git", "gitoxide"] }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
awc = "3.5.0"
|
awc = "3.0.1"
|
||||||
ructe = "0.17.2"
|
ructe = "0.15.0"
|
||||||
tempfile = "3.10.1"
|
tempfile = "3.3.0"
|
||||||
tokio = "1.38.0"
|
tokio = "1.21.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 '/src\/build.rs/d' > \
|
RUN head -n $(($(grep -n "\[build-dependencies\]" Cargo.toml | cut -f1 -d:) - 1)) Cargo.toml | sed '/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,6 +24,7 @@ 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
Normal file
15
build.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
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")
|
||||||
|
}
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
||||||
"extends": [
|
|
||||||
"local>renovate-bot/renovate-config"
|
|
||||||
]
|
|
||||||
}
|
|
12
src/build.rs
12
src/build.rs
@ -1,12 +0,0 @@
|
|||||||
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")?)
|
|
||||||
}
|
|
15
src/cache.rs
15
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.entries.get(branch).map_or_else(
|
Ok(cache
|
||||||
// TODO: get rid of clone
|
.entries
|
||||||
|| CacheState::NoneForBranch(cache.clone()),
|
.get(branch)
|
||||||
|c| {
|
.map(|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,8 +56,9 @@ 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)
|
||||||
}
|
}
|
||||||
@ -74,7 +75,7 @@ impl<'a> CacheState<'a> {
|
|||||||
trace!("Calculating new cache");
|
trace!("Calculating new cache");
|
||||||
match self {
|
match self {
|
||||||
CacheState::Old { mut cache, .. } => {
|
CacheState::Old { mut cache, .. } => {
|
||||||
if let Some(cache) = cache.entries.get_mut(branch) {
|
if let Some(mut cache) = cache.entries.get_mut(branch) {
|
||||||
cache.head = head;
|
cache.head = head;
|
||||||
cache.count += count;
|
cache.count += count;
|
||||||
cache.commits += commits;
|
cache.commits += commits;
|
||||||
|
@ -18,12 +18,6 @@ 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))
|
||||||
|
23
src/error.rs
23
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"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,16 +41,19 @@ impl ResponseError for Error {
|
|||||||
|
|
||||||
fn error_response(&self) -> HttpResponse {
|
fn error_response(&self) -> HttpResponse {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
if let Error::BranchNotFound = self {
|
match self {
|
||||||
templates::p404_no_master_html(&mut buf, VERSION_INFO, 0).unwrap();
|
Error::BranchNotFound => {
|
||||||
|
templates::p404_no_master(&mut buf, VERSION_INFO, 0).unwrap();
|
||||||
HttpResponse::NotFound().content_type("text/html").body(buf)
|
HttpResponse::NotFound().content_type("text/html").body(buf)
|
||||||
} else {
|
}
|
||||||
templates::p500_html(&mut buf, VERSION_INFO, 0).unwrap();
|
_ => {
|
||||||
|
templates::p500(&mut buf, VERSION_INFO, 0).unwrap();
|
||||||
HttpResponse::InternalServerError()
|
HttpResponse::InternalServerError()
|
||||||
.content_type("text/html")
|
.content_type("text/html")
|
||||||
.body(buf)
|
.body(buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for Error {}
|
impl std::error::Error for Error {}
|
||||||
|
91
src/lib.rs
91
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, FormValue, GitHub, Gitlab, Service, Sourcehut},
|
service::{Bitbucket, FormService, 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: FormValue,
|
service: FormService,
|
||||||
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,14 +83,8 @@ struct JsonResponse<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
struct BadgeQuery {
|
struct BranchQuery {
|
||||||
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<()> {
|
||||||
@ -101,8 +95,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!("{cache_dir}/{repo}.json");
|
let cache_dir = format!("{}/{}.json", cache_dir, repo);
|
||||||
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...
|
||||||
@ -124,7 +118,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");
|
||||||
@ -132,8 +126,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");
|
||||||
@ -214,16 +208,16 @@ where
|
|||||||
data.1.to_lowercase()
|
data.1.to_lowercase()
|
||||||
);
|
);
|
||||||
info!("Deleting cache and repository");
|
info!("Deleting cache and repository");
|
||||||
let cache_dir = format!("{}/{repo}.json", &state.cache());
|
let cache_dir = format!("{}/{}.json", &state.cache(), repo);
|
||||||
let repo_dir = format!("{}/{repo}", &state.repos());
|
let repo_dir = format!("{}/{}", &state.repos(), repo);
|
||||||
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 {
|
||||||
@ -262,10 +256,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!("{}/{repo}", T::url_path());
|
let service_path = format!("{}/{}", T::url_path(), repo);
|
||||||
let service_url = format!("{}/{repo}", T::domain());
|
let service_url = format!("{}/{}", T::domain(), repo);
|
||||||
let path = format!("{}/{service_url}", state.repos());
|
let path = format!("{}/{}", state.repos(), service_url);
|
||||||
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() {
|
||||||
@ -282,10 +276,9 @@ where
|
|||||||
}
|
}
|
||||||
pull(&path)?;
|
pull(&path)?;
|
||||||
let (hoc, head, commits) = hoc(&service_url, &state.repos(), &state.cache(), branch)?;
|
let (hoc, head, commits) = hoc(&service_url, &state.repos(), &state.cache(), branch)?;
|
||||||
#[allow(clippy::cast_precision_loss)]
|
|
||||||
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!("{hoc:.1}{prefix}"),
|
NumberPrefix::Prefixed(prefix, hoc) => format!("{:.1}{}", hoc, prefix),
|
||||||
};
|
};
|
||||||
let res = HocResult::Hoc {
|
let res = HocResult::Hoc {
|
||||||
hoc,
|
hoc,
|
||||||
@ -305,12 +298,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<BadgeQuery>,
|
branch: web::Query<BranchQuery>,
|
||||||
) -> 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 {
|
||||||
@ -341,15 +334,14 @@ 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)>,
|
||||||
query: web::Query<BadgeQuery>,
|
branch: web::Query<BranchQuery>,
|
||||||
) -> 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: label,
|
subject: "Hits-of-Code".to_string(),
|
||||||
color: "#007ec6".to_string(),
|
color: "#007ec6".to_string(),
|
||||||
status: hoc_pretty,
|
status: hoc_pretty,
|
||||||
};
|
};
|
||||||
@ -360,10 +352,10 @@ pub(crate) async fn calculate_hoc<T: Service>(
|
|||||||
Ok(no_cache_response(body))
|
Ok(no_cache_response(body))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let branch = query.branch.as_deref().unwrap_or("master");
|
let branch = branch.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: query.label.clone(),
|
subject: "Hits-of-Code".to_string(),
|
||||||
color: "#ff0000".to_string(),
|
color: "#ff0000".to_string(),
|
||||||
status: "error".to_string(),
|
status: "error".to_string(),
|
||||||
})
|
})
|
||||||
@ -380,14 +372,13 @@ 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)>,
|
||||||
query: web::Query<BadgeQuery>,
|
branch: web::Query<BranchQuery>,
|
||||||
) -> Result<HttpResponse> {
|
) -> Result<HttpResponse> {
|
||||||
let branch = query.branch.as_deref().unwrap_or("master");
|
let branch = branch.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,
|
||||||
@ -409,12 +400,11 @@ async fn overview<T: Service>(
|
|||||||
url: &url,
|
url: &url,
|
||||||
branch,
|
branch,
|
||||||
};
|
};
|
||||||
templates::overview_html(
|
templates::overview(
|
||||||
&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,19 +414,17 @@ 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_html(
|
templates::index(
|
||||||
&mut buf,
|
&mut buf,
|
||||||
VERSION_INFO,
|
VERSION_INFO,
|
||||||
repo_count.load(Ordering::Relaxed),
|
repo_count.load(Ordering::Relaxed),
|
||||||
@ -446,7 +434,6 @@ 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>,
|
||||||
@ -463,7 +450,7 @@ async fn generate(
|
|||||||
.filter(|s| !s.is_empty())
|
.filter(|s| !s.is_empty())
|
||||||
.unwrap_or("master"),
|
.unwrap_or("master"),
|
||||||
};
|
};
|
||||||
templates::generate_html(
|
templates::generate(
|
||||||
&mut buf,
|
&mut buf,
|
||||||
VERSION_INFO,
|
VERSION_INFO,
|
||||||
repo_count.load(Ordering::Relaxed),
|
repo_count.load(Ordering::Relaxed),
|
||||||
@ -474,22 +461,20 @@ 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_html(&mut buf, VERSION_INFO, repo_count.load(Ordering::Relaxed))?;
|
templates::p404(&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>,
|
||||||
@ -502,11 +487,11 @@ async fn static_file(
|
|||||||
.content_type(data.mime.clone())
|
.content_type(data.mime.clone())
|
||||||
.body(data.content)
|
.body(data.content)
|
||||||
})
|
})
|
||||||
.map_or_else(|| p404(&repo_count), Result::Ok)
|
.map(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()
|
||||||
@ -514,7 +499,6 @@ 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 =
|
||||||
@ -543,11 +527,6 @@ 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();
|
||||||
|
@ -6,7 +6,7 @@ fn init() {
|
|||||||
dotenvy::dotenv().ok();
|
dotenvy::dotenv().ok();
|
||||||
openssl_probe::init_ssl_cert_env_vars();
|
openssl_probe::init_ssl_cert_env_vars();
|
||||||
|
|
||||||
telemetry::init_subscriber(telemetry::get_subscriber("hoc", "info"));
|
telemetry::init_subscriber(telemetry::get_subscriber("hoc", "info"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::main]
|
#[actix_rt::main]
|
||||||
|
@ -29,7 +29,7 @@ pub(crate) trait Service: Sized + 'static {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Clone, Copy)]
|
#[derive(Deserialize, Serialize, Clone, Copy)]
|
||||||
pub enum FormValue {
|
pub enum FormService {
|
||||||
#[serde(rename = "github")]
|
#[serde(rename = "github")]
|
||||||
GitHub,
|
GitHub,
|
||||||
#[serde(rename = "gitlab")]
|
#[serde(rename = "gitlab")]
|
||||||
@ -40,22 +40,22 @@ pub enum FormValue {
|
|||||||
Sourcehut,
|
Sourcehut,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FormValue {
|
impl FormService {
|
||||||
pub(crate) fn url(&self) -> &str {
|
pub(crate) fn url(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
FormValue::GitHub => "github.com",
|
FormService::GitHub => "github.com",
|
||||||
FormValue::Gitlab => "gitlab.com",
|
FormService::Gitlab => "gitlab.com",
|
||||||
FormValue::Bitbucket => "bitbucket.org",
|
FormService::Bitbucket => "bitbucket.org",
|
||||||
FormValue::Sourcehut => "git.sr.ht",
|
FormService::Sourcehut => "git.sr.ht",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn service(&self) -> &str {
|
pub(crate) fn service(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
FormValue::GitHub => "github",
|
FormService::GitHub => "github",
|
||||||
FormValue::Gitlab => "gitlab",
|
FormService::Gitlab => "gitlab",
|
||||||
FormValue::Bitbucket => "bitbucket",
|
FormService::Bitbucket => "bitbucket",
|
||||||
FormValue::Sourcehut => "sourcehut",
|
FormService::Sourcehut => "sourcehut",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
#[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"),
|
commit: env!("VERGEN_GIT_SHA_SHORT"),
|
||||||
version: env!("CARGO_PKG_VERSION"),
|
version: env!("CARGO_PKG_VERSION"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,10 +15,6 @@ pub fn get_subscriber(name: &str, env_filter: &str) -> impl Subscriber + Send +
|
|||||||
.with(formatting_layer)
|
.with(formatting_layer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Panics
|
|
||||||
///
|
|
||||||
/// This panics if the `LogTracer` cannot be initialized or `subscriber` cannot be set as global
|
|
||||||
/// default.
|
|
||||||
pub fn init_subscriber(subscriber: impl Subscriber + Send + Sync) {
|
pub fn init_subscriber(subscriber: impl Subscriber + Send + Sync) {
|
||||||
LogTracer::init().expect("Failed to set logger");
|
LogTracer::init().expect("Failed to set logger");
|
||||||
set_global_default(subscriber).expect("Failed to set tracing subscriber");
|
set_global_default(subscriber).expect("Failed to set tracing subscriber");
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use crate::service::FormValue;
|
use crate::service::FormService;
|
||||||
|
|
||||||
#[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,
|
||||||
@ -14,7 +13,7 @@ pub struct RepoInfo<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct RepoGeneratorInfo<'a> {
|
pub struct RepoGeneratorInfo<'a> {
|
||||||
pub service: FormValue,
|
pub service: FormService,
|
||||||
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::tacit_css_min_css;
|
@use super::statics::*;
|
||||||
@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_html;
|
@use super::base;
|
||||||
@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_html("Hits-of-Code Badges", "Badge Generator", {
|
@:base("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_html;
|
@use super::base;
|
||||||
@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_html("Hits-of-Code Badges", "Hits-of-Code Badges", {
|
@:base("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,10 +51,6 @@ 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_html;
|
@use super::base;
|
||||||
@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, label: &str)
|
@(version_info: VersionInfo, repo_count: usize, repo_info: RepoInfo)
|
||||||
|
|
||||||
@:base_html("Hits-of-Code Badges", "Overview", {
|
@:base("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>
|
||||||
[![@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)
|
[![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)
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
@use super::base_html;
|
@use super::base;
|
||||||
@use crate::statics::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, repo_count: usize)
|
@(version_info: VersionInfo, repo_count: usize)
|
||||||
|
|
||||||
@:base_html("Page not Found - Hits-of-Code Badges", "404 - Page not Found", {
|
@:base("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_html;
|
@use super::base;
|
||||||
@use crate::statics::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, repo_count: usize)
|
@(version_info: VersionInfo, repo_count: usize)
|
||||||
|
|
||||||
@:base_html("Branch not Found - Hits-of-Code Badges", "404 - Branch not Found", {
|
@:base("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_html;
|
@use super::base;
|
||||||
@use crate::statics::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, repo_count: usize)
|
@(version_info: VersionInfo, repo_count: usize)
|
||||||
|
|
||||||
@:base_html("Internal Server Error - Hits-of-Code Badges", "500 - Internal Server Error", {
|
@:base("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>
|
||||||
|
@ -5,14 +5,14 @@ use tempfile::TempDir;
|
|||||||
#[test]
|
#[test]
|
||||||
fn no_repos() {
|
fn no_repos() {
|
||||||
let repos = TempDir::new().unwrap();
|
let repos = TempDir::new().unwrap();
|
||||||
assert_eq!(0, count_repositories(&repos).unwrap());
|
assert_eq!(0, count_repositories(&repos).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_repos_for_provider() {
|
fn no_repos_for_provider() {
|
||||||
let repos = TempDir::new().unwrap();
|
let repos = TempDir::new().unwrap();
|
||||||
let _provider = TempDir::new_in(&repos).unwrap();
|
let _provider = TempDir::new_in(&repos).unwrap();
|
||||||
assert_eq!(0, count_repositories(&repos).unwrap());
|
assert_eq!(0, count_repositories(&repos).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -20,7 +20,7 @@ fn no_repos_for_owner() {
|
|||||||
let repos = TempDir::new().unwrap();
|
let repos = TempDir::new().unwrap();
|
||||||
let provider = TempDir::new_in(&repos).unwrap();
|
let provider = TempDir::new_in(&repos).unwrap();
|
||||||
let _owner = TempDir::new_in(&provider).unwrap();
|
let _owner = TempDir::new_in(&provider).unwrap();
|
||||||
assert_eq!(0, count_repositories(&repos).unwrap());
|
assert_eq!(0, count_repositories(&repos).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -29,7 +29,7 @@ fn one_repo_for_owner() {
|
|||||||
let provider = TempDir::new_in(&repos).unwrap();
|
let provider = TempDir::new_in(&repos).unwrap();
|
||||||
let owner = TempDir::new_in(&provider).unwrap();
|
let owner = TempDir::new_in(&provider).unwrap();
|
||||||
let _repo = TempDir::new_in(&owner).unwrap();
|
let _repo = TempDir::new_in(&owner).unwrap();
|
||||||
assert_eq!(1, count_repositories(&repos).unwrap());
|
assert_eq!(1, count_repositories(&repos).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -39,7 +39,7 @@ fn two_repos_for_owner() {
|
|||||||
let owner = TempDir::new_in(&provider).unwrap();
|
let owner = TempDir::new_in(&provider).unwrap();
|
||||||
let _repo1 = TempDir::new_in(&owner).unwrap();
|
let _repo1 = TempDir::new_in(&owner).unwrap();
|
||||||
let _repo2 = TempDir::new_in(&owner).unwrap();
|
let _repo2 = TempDir::new_in(&owner).unwrap();
|
||||||
assert_eq!(2, count_repositories(&repos).unwrap());
|
assert_eq!(2, count_repositories(&repos).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -51,7 +51,7 @@ fn two_repos_for_two_providers() {
|
|||||||
let provider2 = TempDir::new_in(&repos).unwrap();
|
let provider2 = TempDir::new_in(&repos).unwrap();
|
||||||
let owner2 = TempDir::new_in(&provider2).unwrap();
|
let owner2 = TempDir::new_in(&provider2).unwrap();
|
||||||
let _repo2 = TempDir::new_in(&owner2).unwrap();
|
let _repo2 = TempDir::new_in(&owner2).unwrap();
|
||||||
assert_eq!(2, count_repositories(&repos).unwrap());
|
assert_eq!(2, count_repositories(&repos).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -62,5 +62,5 @@ fn two_subdirs_in_one_repo() {
|
|||||||
let repo = TempDir::new_in(&owner).unwrap();
|
let repo = TempDir::new_in(&owner).unwrap();
|
||||||
let _subdir1 = TempDir::new_in(&repo).unwrap();
|
let _subdir1 = TempDir::new_in(&repo).unwrap();
|
||||||
let _subdir2 = TempDir::new_in(&repo).unwrap();
|
let _subdir2 = TempDir::new_in(&repo).unwrap();
|
||||||
assert_eq!(1, count_repositories(&repos).unwrap());
|
assert_eq!(1, count_repositories(&repos).unwrap())
|
||||||
}
|
}
|
||||||
|
@ -25,26 +25,24 @@ pub async fn spawn_app() -> TestApp {
|
|||||||
let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind random port");
|
let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind random port");
|
||||||
|
|
||||||
let port = listener.local_addr().unwrap().port();
|
let port = listener.local_addr().unwrap().port();
|
||||||
let address = format!("http://127.0.0.1:{port}");
|
let address = format!("http://127.0.0.1:{}", port);
|
||||||
|
|
||||||
let repo_dir = tempdir().expect("Cannot create repo_dir");
|
let _repo_dir = tempdir().expect("Cannot create repo_dir");
|
||||||
let cache_dir = tempdir().expect("Cannot create cache_dir");
|
let _cache_dir = tempdir().expect("Cannot create cache_dir");
|
||||||
|
|
||||||
let mut settings = Settings::load().expect("Failed to read configuration.");
|
let mut settings = Settings::load().expect("Failed to read configuration.");
|
||||||
settings.repodir = repo_dir.path().to_path_buf();
|
settings.repodir = _repo_dir.path().to_path_buf();
|
||||||
settings.cachedir = cache_dir.path().to_path_buf();
|
settings.cachedir = _cache_dir.path().to_path_buf();
|
||||||
|
|
||||||
let server = hoc::run(listener, settings)
|
let server = hoc::run(listener, settings)
|
||||||
.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 {
|
||||||
address,
|
address,
|
||||||
_repo_dir: repo_dir,
|
_repo_dir,
|
||||||
_cache_dir: cache_dir,
|
_cache_dir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user