Compare commits
200 Commits
Author | SHA1 | Date | |
---|---|---|---|
1010d5cf0d | |||
6896a22409 | |||
3c2f06ebae | |||
3c945f5762 | |||
903abdefdc | |||
01689fc89e | |||
ede937d651 | |||
1805d86048 | |||
a81de6f89c | |||
dfc49c6b64 | |||
c7cde6222a | |||
fb889aa0ec | |||
36f29a410b | |||
e65efb5ea1 | |||
2127dbe879 | |||
9fe0c080c7 | |||
5f132ed0c8 | |||
5fe25b83e1 | |||
72655edcfc | |||
2ef4412f0a | |||
3863a870c5 | |||
7e29eab063 | |||
303445f3ad | |||
6a03ae9fff | |||
9ac60b8a26 | |||
d2c23ebf4f | |||
d0ddc7f62d | |||
164c97f453 | |||
c702bec8e2 | |||
2c002a1865 | |||
95efa4d875 | |||
65f1575045 | |||
9f95ae74a4 | |||
37159f8909 | |||
0142425f1e | |||
b72641221b | |||
50d985ffd4 | |||
8b0cc49724 | |||
6d0d53af1b | |||
b666a3e3b3 | |||
f5b37ba700 | |||
beb3c8330c | |||
34ee7e3853 | |||
84cf8b9a6f | |||
9ef0337605 | |||
bbf5bba490 | |||
9991f6c545 | |||
37e3c5ee72 | |||
edab6fd3dd | |||
97197190f5 | |||
4959fabd29 | |||
fecd5d0b6a | |||
1060edaebe | |||
bc9f411297 | |||
7fc920cddd | |||
6a4c1edf9e | |||
c1ea45d517 | |||
0b729da42f | |||
c0d0aa2176 | |||
41159c4ba4 | |||
b40b6bcad2 | |||
6e86f49585 | |||
c8c73b6b83 | |||
c6cc956f4d | |||
e37489d2cb | |||
8246be996e | |||
1f32f3eda4 | |||
ab6c317241 | |||
1223d429db | |||
9613aa7848 | |||
334fa8ced5 | |||
062343dd32 | |||
bdb2a151fa | |||
7e66393966 | |||
32ac5ca0d8 | |||
b3b4cd0e42 | |||
be08b87bbb | |||
cf4d427b96 | |||
b5ebc54372 | |||
231741629e | |||
135c5756b1 | |||
79cfee5fa5 | |||
1c9b5db4e1 | |||
6e0e452395 | |||
9e44731650 | |||
f673d71387 | |||
eda1822dce | |||
fb64af3456 | |||
0837284798 | |||
a7039f15b5 | |||
b1be281982 | |||
2795995f58 | |||
913cc9dc75 | |||
645d6e4a2b | |||
e455a89de4 | |||
f2cae46624 | |||
f47cbbe81a | |||
85f90c0bdb | |||
9143e5dbf8 | |||
865e3c7bbd | |||
5ebdd4067c | |||
55a1405e71 | |||
1436336b6a | |||
5a74306e49 | |||
614e5a6da5 | |||
0128e267cc | |||
c3dffac5da | |||
aaaff22907 | |||
ddfcbf11f1 | |||
3bee454548 | |||
9cff6f1f13 | |||
c946c5d0b4 | |||
88ae90af95 | |||
9f783dffa8 | |||
2cdf64ed80 | |||
9e024b530e | |||
0db7b26541 | |||
009d2c4813 | |||
f0ed6c2e23 | |||
d16a21e74e | |||
7e721ac212 | |||
4eb5d06cd1 | |||
b71207ca51 | |||
f3902f800f | |||
b8e454762e | |||
268734efdd | |||
c71925f61e | |||
c5bbd14a05 | |||
a239a3f80b | |||
00b4e60341 | |||
ed1cafafd0 | |||
bdb10fd54a | |||
1f01c3b964 | |||
3f94789b8b | |||
e4f8604861 | |||
25a179dad6 | |||
6ee44f7ba3 | |||
e9ebbee957 | |||
5211481226 | |||
fd230db0cb | |||
92a95f33d4 | |||
7e13f93ee3 | |||
36afc8732e | |||
abeed1f971 | |||
03a0743517 | |||
cbfd56b33a | |||
9c5208d6e4 | |||
92d7b6668a | |||
97510fa325 | |||
65ba104de1 | |||
9599d934a2 | |||
61e2dd174a | |||
fe00cddd47 | |||
9b73c99922 | |||
ed3da3a2c3 | |||
504476b145 | |||
9bc1b42750 | |||
140265b713 | |||
4446d9b879 | |||
ac8ba338bb | |||
d609f9bf43 | |||
6bc783451e | |||
21243e6cfb | |||
05736ee3ba | |||
d23588172b | |||
ce77854754 | |||
70e83d8cee | |||
284e41c591 | |||
ec8bbe0325 | |||
8d4de48c11 | |||
eb718990ec | |||
60dc242e5a | |||
615460c87b | |||
ba6fc7d394 | |||
5551c6f3e4 | |||
38399b0bcd | |||
ad4d87ca2f | |||
137f264bdf | |||
8cfe84c763 | |||
787ff55444 | |||
3901fe9e9c | |||
e0b6ee69f1 | |||
75398a3613 | |||
a944e8b149 | |||
d9faf25648 | |||
d2977eee32 | |||
569ce3a457 | |||
a77962732e | |||
6438bbba82 | |||
0fcafc7e4b | |||
5fd0eaf289 | |||
2236cf8b53 | |||
60cba9951f | |||
d6835b96de | |||
6d980d92be | |||
48e65fef36 | |||
514c30e13c | |||
d082531ca4 | |||
0a58a75cd1 | |||
a7441f79cb |
31
.github/workflows/audit.yml
vendored
Normal file
31
.github/workflows/audit.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
name: Security audit
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 1 * * *'
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- 'Cargo.toml'
|
||||||
|
- 'Cargo.lock'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security_audit:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- name: Cache cargo registry
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: /usr/share/rust/.cargo/registry
|
||||||
|
key: ${{ runner.os }}-cargo-registry
|
||||||
|
|
||||||
|
- name: Cache cargo index
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: /usr/share/rust/.cargo/git
|
||||||
|
key: ${{ runner.os }}-cargo-index
|
||||||
|
|
||||||
|
- uses: actions-rs/audit-check@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
94
.github/workflows/rust.yml
vendored
Normal file
94
.github/workflows/rust.yml
vendored
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
name: Rust
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Linting and Formatting Checks
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- name: Install stable toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Install rustfmt
|
||||||
|
run: rustup component add rustfmt
|
||||||
|
|
||||||
|
- name: Cache cargo registry
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/.cargo/registry
|
||||||
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
|
- name: Cache cargo index
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/.cargo/git
|
||||||
|
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
|
- name: Cache cargo build
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: target
|
||||||
|
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
|
- name: Check Formatting
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: --all -- --check
|
||||||
|
|
||||||
|
- name: Install clippy
|
||||||
|
run: rustup component add clippy
|
||||||
|
|
||||||
|
- name: Clippy Linting
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: clippy
|
||||||
|
args: -- -D warnings
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Run Tests
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
# add windows-latest when it is clear why tests are failing
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- name: Install stable toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Cache cargo registry
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/.cargo/registry
|
||||||
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
|
- name: Cache cargo index
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/.cargo/git
|
||||||
|
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
|
- name: Cache cargo build
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: target
|
||||||
|
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
repos
|
repos
|
||||||
cache
|
cache
|
||||||
|
hoc.log
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
image: docker:stable
|
image: docker:19.03
|
||||||
services:
|
services:
|
||||||
- docker:dind
|
- docker:19.03-dind
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
@ -9,6 +9,8 @@ stages:
|
|||||||
variables:
|
variables:
|
||||||
DOCKER_HOST: tcp://docker:2375
|
DOCKER_HOST: tcp://docker:2375
|
||||||
DOCKER_DRIVER: overlay2
|
DOCKER_DRIVER: overlay2
|
||||||
|
# DOCKER_TLS_CERTDIR: "/certs"
|
||||||
|
DOCKER_TLS_CERTDIR: ""
|
||||||
CONTAINER_BUILDER_IMAGE: $CI_REGISTRY_IMAGE:builder-latest
|
CONTAINER_BUILDER_IMAGE: $CI_REGISTRY_IMAGE:builder-latest
|
||||||
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
||||||
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
|
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
|
||||||
|
2869
Cargo.lock
generated
2869
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
29
Cargo.toml
29
Cargo.toml
@ -1,27 +1,28 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "hoc"
|
name = "hoc"
|
||||||
version = "0.3.0"
|
version = "0.11.5"
|
||||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "1.0.0-beta.2"
|
actix-web = "2.0.0"
|
||||||
badge = "0.2.0"
|
badge = "0.2.0"
|
||||||
bytes = "0.4.12"
|
bytes = "0.5.4"
|
||||||
futures = "0.1.26"
|
futures = "0.3.1"
|
||||||
git2 = "0.8.0"
|
git2 = "0.11.0"
|
||||||
lazy_static = "1.3.0"
|
lazy_static = "1.4.0"
|
||||||
log = "0.4.6"
|
log = "0.4.8"
|
||||||
|
log4rs = "0.10.0"
|
||||||
number_prefix = "0.3.0"
|
number_prefix = "0.3.0"
|
||||||
openssl-probe = "0.1.2"
|
openssl-probe = "0.1.2"
|
||||||
pretty_env_logger = "0.3.0"
|
reqwest = "0.10.1"
|
||||||
reqwest = "0.9.16"
|
serde = "1.0.104"
|
||||||
serde = "1.0.90"
|
serde_derive = "1.0.103"
|
||||||
serde_derive = "1.0.90"
|
serde_json = "1.0.47"
|
||||||
serde_json = "1.0.39"
|
structopt = "0.3.9"
|
||||||
structopt = "0.2.15"
|
actix-rt = "1.0.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
ructe = "0.6.2"
|
ructe = "0.9.2"
|
||||||
vergen = "3.0.4"
|
vergen = "3.0.4"
|
||||||
|
@ -29,10 +29,14 @@ FROM alpine:latest
|
|||||||
|
|
||||||
RUN apk --no-cache add --update git
|
RUN apk --no-cache add --update git
|
||||||
|
|
||||||
|
RUN adduser -D hoc
|
||||||
|
WORKDIR /home/hoc
|
||||||
|
USER hoc
|
||||||
|
|
||||||
# once we don't need a git binary anymore, this should be enough
|
# once we don't need a git binary anymore, this should be enough
|
||||||
# FROM scratch
|
# FROM scratch
|
||||||
# COPY --from=linuxkit/ca-certificates:v0.7 / /
|
# COPY --from=linuxkit/ca-certificates:v0.7 / /
|
||||||
|
|
||||||
COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/hoc /hoc
|
COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/hoc .
|
||||||
|
|
||||||
ENTRYPOINT ["/hoc"]
|
ENTRYPOINT ["/home/hoc/hoc"]
|
||||||
|
@ -20,8 +20,14 @@ The API is as simple as
|
|||||||
https://<host>/<service>/<user>/<repo>
|
https://<host>/<service>/<user>/<repo>
|
||||||
```
|
```
|
||||||
|
|
||||||
where `<service>` is one of `gitub`, `gitlab` or `bitbucket`.
|
where `<service>` is one of `gitub`, `gitlab` or `bitbucket`. The HoC data can also be received as JSON by appending
|
||||||
|
`/json` to the reuqest path:
|
||||||
|
|
||||||
|
```
|
||||||
|
https://<host>/<service>/<user>/<repo>/json
|
||||||
|
```
|
||||||
|
|
||||||
|
There is also an overview page available via `https://<host>/view/<service>/<user>/<repo>`
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
|
@ -2,11 +2,10 @@ version: "2"
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
hoc:
|
hoc:
|
||||||
# build: .
|
image: vbrandl/hits-of-code:latest
|
||||||
# image: local/hoc:latest
|
|
||||||
image: registry.gitlab.com/vbrandl/hoc:latest
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./repos:/repos
|
- ./repos:/home/hoc/repos
|
||||||
- ./cache:/cache
|
- ./cache:/home/hoc/cache
|
||||||
ports:
|
# ports:
|
||||||
- "127.0.0.1:8080:8080"
|
# - "127.0.0.1:8080:8080"
|
||||||
|
restart: always
|
||||||
|
10
scripts/find-active.sh
Executable file
10
scripts/find-active.sh
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR=${1:-repos}
|
||||||
|
|
||||||
|
for url in $(./scripts/list.sh "${DIR}")
|
||||||
|
do
|
||||||
|
(curl "${url}" --silent | grep -q hitsofcode) && echo "${url}" &
|
||||||
|
done
|
9
scripts/list.sh
Executable file
9
scripts/list.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR=${1:-repos}
|
||||||
|
|
||||||
|
find "$DIR" -mindepth 3 -maxdepth 3 -type d \
|
||||||
|
| sed -e "s/$DIR/https:\//g" \
|
||||||
|
| sort
|
21
scripts/load-active.sh
Executable file
21
scripts/load-active.sh
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
ACTIVE=${1}
|
||||||
|
|
||||||
|
if [ -z "${ACTIVE}" ]
|
||||||
|
then
|
||||||
|
echo "Usage: $0 <list of active repos>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
while IFS= read -r url
|
||||||
|
do
|
||||||
|
imgs=$(curl "${url}" --silent | grep hitsofcode | grep -o -P 'https://camo.githubusercontent.com/[a-z0-9]+/[a-z0-9]+')
|
||||||
|
[ -z "${imgs}" ] || echo "${url}"
|
||||||
|
for img in ${imgs}
|
||||||
|
do
|
||||||
|
curl "$img" --silent > /dev/null &
|
||||||
|
done
|
||||||
|
done < "${ACTIVE}"
|
26
src/cache.rs
26
src/cache.rs
@ -1,4 +1,4 @@
|
|||||||
use crate::Error;
|
use crate::error::{Error, Result};
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
fs::{create_dir_all, File, OpenOptions},
|
fs::{create_dir_all, File, OpenOptions},
|
||||||
@ -9,7 +9,7 @@ use std::{
|
|||||||
/// Enum to indicate the state of the cache
|
/// Enum to indicate the state of the cache
|
||||||
pub(crate) enum CacheState<'a> {
|
pub(crate) enum CacheState<'a> {
|
||||||
/// Current head and cached head are the same
|
/// Current head and cached head are the same
|
||||||
Current(u64),
|
Current { count: u64, commits: u64 },
|
||||||
/// Cached head is older than current head
|
/// Cached head is older than current head
|
||||||
Old(Cache<'a>),
|
Old(Cache<'a>),
|
||||||
/// No cache was found
|
/// No cache was found
|
||||||
@ -17,11 +17,14 @@ pub(crate) enum CacheState<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CacheState<'a> {
|
impl<'a> CacheState<'a> {
|
||||||
pub(crate) fn read_from_file(path: impl AsRef<Path>, head: &str) -> Result<CacheState, Error> {
|
pub(crate) fn read_from_file(path: impl AsRef<Path>, head: &str) -> Result<CacheState> {
|
||||||
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)?))?;
|
||||||
if cache.head == head {
|
if cache.head == head {
|
||||||
Ok(CacheState::Current(cache.count))
|
Ok(CacheState::Current {
|
||||||
|
count: cache.count,
|
||||||
|
commits: cache.commits,
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
Ok(CacheState::Old(cache))
|
Ok(CacheState::Old(cache))
|
||||||
}
|
}
|
||||||
@ -30,26 +33,35 @@ impl<'a> CacheState<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn calculate_new_cache(self, count: u64, head: Cow<'a, str>) -> Cache {
|
pub(crate) fn calculate_new_cache(self, count: u64, commits: u64, head: Cow<'a, str>) -> Cache {
|
||||||
match self {
|
match self {
|
||||||
CacheState::Old(mut cache) => {
|
CacheState::Old(mut cache) => {
|
||||||
cache.head = head;
|
cache.head = head;
|
||||||
cache.count += count;
|
cache.count += count;
|
||||||
|
cache.commits += commits;
|
||||||
cache
|
cache
|
||||||
}
|
}
|
||||||
CacheState::No | CacheState::Current(_) => Cache { head, count },
|
CacheState::No | CacheState::Current { .. } => Cache {
|
||||||
|
head,
|
||||||
|
count,
|
||||||
|
commits,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub(crate) struct Cache<'a> {
|
pub(crate) struct Cache<'a> {
|
||||||
|
/// HEAD commit ref
|
||||||
pub head: Cow<'a, str>,
|
pub head: Cow<'a, str>,
|
||||||
|
/// HoC value
|
||||||
pub count: u64,
|
pub count: u64,
|
||||||
|
/// Number of commits
|
||||||
|
pub commits: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Cache<'a> {
|
impl<'a> Cache<'a> {
|
||||||
pub(crate) fn write_to_file(&self, path: impl AsRef<Path>) -> Result<(), Error> {
|
pub(crate) fn write_to_file(&self, path: impl AsRef<Path>) -> Result<()> {
|
||||||
create_dir_all(path.as_ref().parent().ok_or(Error::Internal)?)?;
|
create_dir_all(path.as_ref().parent().ok_or(Error::Internal)?)?;
|
||||||
serde_json::to_writer(
|
serde_json::to_writer(
|
||||||
OpenOptions::new()
|
OpenOptions::new()
|
||||||
|
71
src/config.rs
Normal file
71
src/config.rs
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
use crate::{error::Result, statics::OPT};
|
||||||
|
use log::LevelFilter;
|
||||||
|
use log4rs::{
|
||||||
|
append::{console::ConsoleAppender, file::FileAppender},
|
||||||
|
config::{Appender, Config, Root},
|
||||||
|
encode::pattern::PatternEncoder,
|
||||||
|
};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use structopt::StructOpt;
|
||||||
|
|
||||||
|
#[derive(StructOpt, Debug)]
|
||||||
|
pub(crate) struct Opt {
|
||||||
|
#[structopt(
|
||||||
|
short = "o",
|
||||||
|
long = "outdir",
|
||||||
|
parse(from_os_str),
|
||||||
|
default_value = "./repos"
|
||||||
|
)]
|
||||||
|
/// Path to store cloned repositories
|
||||||
|
pub(crate) outdir: PathBuf,
|
||||||
|
#[structopt(
|
||||||
|
short = "c",
|
||||||
|
long = "cachedir",
|
||||||
|
parse(from_os_str),
|
||||||
|
default_value = "./cache"
|
||||||
|
)]
|
||||||
|
/// Path to store cache
|
||||||
|
pub(crate) cachedir: PathBuf,
|
||||||
|
#[structopt(short = "p", long = "port", default_value = "8080")]
|
||||||
|
/// Port to listen on
|
||||||
|
pub(crate) port: u16,
|
||||||
|
#[structopt(short = "h", long = "host", default_value = "0.0.0.0")]
|
||||||
|
/// Interface to listen on
|
||||||
|
pub(crate) host: String,
|
||||||
|
#[structopt(short = "d", long = "domain", default_value = "hitsofcode.com")]
|
||||||
|
/// Interface to listen on
|
||||||
|
pub(crate) domain: String,
|
||||||
|
#[structopt(short = "w", long = "workers", default_value = "4")]
|
||||||
|
/// Number of worker threads
|
||||||
|
pub(crate) workers: usize,
|
||||||
|
#[structopt(
|
||||||
|
short = "l",
|
||||||
|
long = "logfile",
|
||||||
|
parse(from_os_str),
|
||||||
|
default_value = "./hoc.log"
|
||||||
|
)]
|
||||||
|
/// The logfile
|
||||||
|
pub(crate) logfile: PathBuf,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn init() -> Result<()> {
|
||||||
|
std::env::set_var("RUST_LOG", "actix_web=info,hoc=info");
|
||||||
|
// pretty_env_logger::init();
|
||||||
|
openssl_probe::init_ssl_cert_env_vars();
|
||||||
|
let stdout = ConsoleAppender::builder().build();
|
||||||
|
let file = FileAppender::builder()
|
||||||
|
.encoder(Box::new(PatternEncoder::new("{d} - {m}{n}")))
|
||||||
|
.build(&OPT.logfile)
|
||||||
|
.unwrap();
|
||||||
|
let config = Config::builder()
|
||||||
|
.appender(Appender::builder().build("stdout", Box::new(stdout)))
|
||||||
|
.appender(Appender::builder().build("file", Box::new(file)))
|
||||||
|
.build(
|
||||||
|
Root::builder()
|
||||||
|
.appender("stdout")
|
||||||
|
.appender("file")
|
||||||
|
.build(LevelFilter::Info),
|
||||||
|
)?;
|
||||||
|
log4rs::init_config(config)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
24
src/count.rs
Normal file
24
src/count.rs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
use crate::error::Result;
|
||||||
|
use std::{fs::read_dir, path::Path, result::Result as StdResult};
|
||||||
|
|
||||||
|
pub(crate) fn count_repositories<P>(repo_path: P) -> Result<usize>
|
||||||
|
where
|
||||||
|
P: AsRef<Path>,
|
||||||
|
{
|
||||||
|
Ok(read_dir(repo_path)?
|
||||||
|
.filter_map(StdResult::ok)
|
||||||
|
.filter(|entry| entry.file_type().map(|ft| ft.is_dir()).unwrap_or(false))
|
||||||
|
.map(|entry| read_dir(entry.path()))
|
||||||
|
.filter_map(StdResult::ok)
|
||||||
|
.flat_map(|dir| {
|
||||||
|
dir.filter_map(StdResult::ok)
|
||||||
|
.filter(|entry| entry.file_type().map(|ft| ft.is_dir()).unwrap_or(false))
|
||||||
|
})
|
||||||
|
.map(|entry| read_dir(entry.path()))
|
||||||
|
.filter_map(StdResult::ok)
|
||||||
|
.flat_map(|dir| {
|
||||||
|
dir.filter_map(StdResult::ok)
|
||||||
|
.filter(|entry| entry.file_type().map(|ft| ft.is_dir()).unwrap_or(false))
|
||||||
|
})
|
||||||
|
.count())
|
||||||
|
}
|
57
src/error.rs
57
src/error.rs
@ -1,6 +1,9 @@
|
|||||||
use crate::P500;
|
use crate::{
|
||||||
|
statics::{REPO_COUNT, VERSION_INFO},
|
||||||
|
templates,
|
||||||
|
};
|
||||||
use actix_web::{HttpResponse, ResponseError};
|
use actix_web::{HttpResponse, ResponseError};
|
||||||
use std::fmt;
|
use std::{fmt, sync::atomic::Ordering};
|
||||||
|
|
||||||
pub(crate) type Result<T> = std::result::Result<T, Error>;
|
pub(crate) type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
@ -11,7 +14,11 @@ pub(crate) enum Error {
|
|||||||
Git(git2::Error),
|
Git(git2::Error),
|
||||||
Internal,
|
Internal,
|
||||||
Io(std::io::Error),
|
Io(std::io::Error),
|
||||||
|
Log(log::SetLoggerError),
|
||||||
|
LogBuilder(log4rs::config::Errors),
|
||||||
|
Parse(std::num::ParseIntError),
|
||||||
Serial(serde_json::Error),
|
Serial(serde_json::Error),
|
||||||
|
GitNoMaster,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
@ -22,22 +29,32 @@ impl fmt::Display for Error {
|
|||||||
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::Log(e) => write!(fmt, "Log({})", e),
|
||||||
|
Error::LogBuilder(e) => write!(fmt, "LogBuilder({})", e),
|
||||||
|
Error::Parse(e) => write!(fmt, "Parse({})", e),
|
||||||
Error::Serial(e) => write!(fmt, "Serial({})", e),
|
Error::Serial(e) => write!(fmt, "Serial({})", e),
|
||||||
|
Error::GitNoMaster => write!(fmt, "Repo doesn't have master branch"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ResponseError for Error {
|
impl ResponseError for Error {
|
||||||
fn error_response(&self) -> HttpResponse {
|
fn error_response(&self) -> HttpResponse {
|
||||||
HttpResponse::InternalServerError()
|
let mut buf = Vec::new();
|
||||||
.content_type("text/html")
|
match self {
|
||||||
.body(P500.as_slice())
|
Error::GitNoMaster => {
|
||||||
}
|
templates::p404_no_master(&mut buf, VERSION_INFO, REPO_COUNT.load(Ordering::Relaxed)).unwrap();
|
||||||
|
HttpResponse::NotFound()
|
||||||
fn render_response(&self) -> HttpResponse {
|
.content_type("text/html")
|
||||||
HttpResponse::InternalServerError()
|
.body(buf)
|
||||||
.content_type("text/html")
|
},
|
||||||
.body(P500.as_slice())
|
_ => {
|
||||||
|
templates::p500(&mut buf, VERSION_INFO, REPO_COUNT.load(Ordering::Relaxed)).unwrap();
|
||||||
|
HttpResponse::InternalServerError()
|
||||||
|
.content_type("text/html")
|
||||||
|
.body(buf)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +72,12 @@ impl From<git2::Error> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<log::SetLoggerError> for Error {
|
||||||
|
fn from(err: log::SetLoggerError) -> Self {
|
||||||
|
Error::Log(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<std::io::Error> for Error {
|
impl From<std::io::Error> for Error {
|
||||||
fn from(err: std::io::Error) -> Self {
|
fn from(err: std::io::Error) -> Self {
|
||||||
Error::Io(err)
|
Error::Io(err)
|
||||||
@ -72,3 +95,15 @@ impl From<reqwest::Error> for Error {
|
|||||||
Error::Client(err)
|
Error::Client(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<log4rs::config::Errors> for Error {
|
||||||
|
fn from(err: log4rs::config::Errors) -> Self {
|
||||||
|
Error::LogBuilder(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<std::num::ParseIntError> for Error {
|
||||||
|
fn from(err: std::num::ParseIntError) -> Self {
|
||||||
|
Error::Parse(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
270
src/main.rs
270
src/main.rs
@ -1,3 +1,5 @@
|
|||||||
|
#![type_length_limit = "2257138"]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate actix_web;
|
extern crate actix_web;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
@ -8,41 +10,40 @@ extern crate log;
|
|||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
|
|
||||||
mod cache;
|
mod cache;
|
||||||
|
mod config;
|
||||||
|
mod count;
|
||||||
mod error;
|
mod error;
|
||||||
mod service;
|
mod service;
|
||||||
|
mod statics;
|
||||||
|
mod template;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
cache::CacheState,
|
cache::CacheState,
|
||||||
error::{Error, Result},
|
error::{Error, Result},
|
||||||
service::{Bitbucket, FormService, GitHub, Gitlab, Service},
|
service::{Bitbucket, FormService, GitHub, Gitlab, Service},
|
||||||
|
statics::{CLIENT, CSS, FAVICON, OPT, REPO_COUNT, VERSION_INFO},
|
||||||
|
template::RepoInfo,
|
||||||
};
|
};
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
error::ErrorBadRequest,
|
|
||||||
http::header::{CacheControl, CacheDirective, Expires},
|
http::header::{CacheControl, CacheDirective, Expires},
|
||||||
middleware, web, App, HttpResponse, HttpServer,
|
middleware, web, App, HttpResponse, HttpServer,
|
||||||
};
|
};
|
||||||
use badge::{Badge, BadgeOptions};
|
use badge::{Badge, BadgeOptions};
|
||||||
use bytes::Bytes;
|
use futures::future::Future;
|
||||||
use futures::{unsync::mpsc, Stream};
|
|
||||||
use git2::Repository;
|
use git2::Repository;
|
||||||
use number_prefix::{NumberPrefix, Prefixed, Standalone};
|
use number_prefix::{NumberPrefix, Prefixed, Standalone};
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
fs::create_dir_all,
|
fs::create_dir_all,
|
||||||
path::{Path, PathBuf},
|
path::Path,
|
||||||
process::Command,
|
process::Command,
|
||||||
|
sync::atomic::Ordering,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::{Duration, SystemTime},
|
time::{Duration, SystemTime},
|
||||||
};
|
};
|
||||||
use structopt::StructOpt;
|
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
|
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
|
||||||
|
|
||||||
pub struct VersionInfo<'a> {
|
|
||||||
pub commit: &'a str,
|
|
||||||
pub version: &'a str,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
struct GeneratorForm<'a> {
|
struct GeneratorForm<'a> {
|
||||||
service: FormService,
|
service: FormService,
|
||||||
@ -50,68 +51,16 @@ struct GeneratorForm<'a> {
|
|||||||
repo: Cow<'a, str>,
|
repo: Cow<'a, str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const VERSION_INFO: VersionInfo = VersionInfo {
|
|
||||||
commit: env!("VERGEN_SHA_SHORT"),
|
|
||||||
version: env!("CARGO_PKG_VERSION"),
|
|
||||||
};
|
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
static ref CLIENT: reqwest::Client = reqwest::Client::new();
|
|
||||||
static ref OPT: Opt = Opt::from_args();
|
|
||||||
static ref INDEX: Vec<u8> = {
|
|
||||||
let mut buf = Vec::new();
|
|
||||||
templates::index(&mut buf, VERSION_INFO, &OPT.domain).unwrap();
|
|
||||||
buf
|
|
||||||
};
|
|
||||||
static ref P404: Vec<u8> = {
|
|
||||||
let mut buf = Vec::new();
|
|
||||||
templates::p404(&mut buf, VERSION_INFO).unwrap();
|
|
||||||
buf
|
|
||||||
};
|
|
||||||
static ref P500: Vec<u8> = {
|
|
||||||
let mut buf = Vec::new();
|
|
||||||
templates::p500(&mut buf, VERSION_INFO).unwrap();
|
|
||||||
buf
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
repos: String,
|
repos: String,
|
||||||
cache: String,
|
cache: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
const CSS: &str = include_str!("../static/tacit-css.min.css");
|
#[derive(Serialize)]
|
||||||
|
struct JsonResponse<'a> {
|
||||||
#[derive(StructOpt, Debug)]
|
head: &'a str,
|
||||||
struct Opt {
|
count: u64,
|
||||||
#[structopt(
|
commits: u64,
|
||||||
short = "o",
|
|
||||||
long = "outdir",
|
|
||||||
parse(from_os_str),
|
|
||||||
default_value = "./repos"
|
|
||||||
)]
|
|
||||||
/// Path to store cloned repositories
|
|
||||||
outdir: PathBuf,
|
|
||||||
#[structopt(
|
|
||||||
short = "c",
|
|
||||||
long = "cachedir",
|
|
||||||
parse(from_os_str),
|
|
||||||
default_value = "./cache"
|
|
||||||
)]
|
|
||||||
/// Path to store cache
|
|
||||||
cachedir: PathBuf,
|
|
||||||
#[structopt(short = "p", long = "port", default_value = "8080")]
|
|
||||||
/// Port to listen on
|
|
||||||
port: u16,
|
|
||||||
#[structopt(short = "h", long = "host", default_value = "0.0.0.0")]
|
|
||||||
/// Interface to listen on
|
|
||||||
host: String,
|
|
||||||
#[structopt(short = "d", long = "domain", default_value = "hitsofcode.com")]
|
|
||||||
/// Interface to listen on
|
|
||||||
domain: String,
|
|
||||||
#[structopt(short = "w", long = "workers", default_value = "4")]
|
|
||||||
/// Number of worker threads
|
|
||||||
workers: usize,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pull(path: impl AsRef<Path>) -> Result<()> {
|
fn pull(path: impl AsRef<Path>) -> Result<()> {
|
||||||
@ -121,17 +70,18 @@ fn pull(path: impl AsRef<Path>) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hoc(repo: &str, repo_dir: &str, cache_dir: &str) -> Result<(u64, String)> {
|
fn hoc(repo: &str, repo_dir: &str, cache_dir: &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!("{}/{}.json", cache_dir, repo);
|
||||||
let cache_dir = Path::new(&cache_dir);
|
let cache_dir = Path::new(&cache_dir);
|
||||||
let head = format!(
|
let repo = Repository::open_bare(&repo_dir)?;
|
||||||
"{}",
|
// TODO: do better...
|
||||||
Repository::open_bare(&repo_dir)?
|
let head = match repo.head() {
|
||||||
.head()?
|
Ok(v) => v,
|
||||||
.target()
|
Err(_) => return Err(Error::GitNoMaster),
|
||||||
.ok_or(Error::Internal)?
|
};
|
||||||
);
|
let head = format!("{}", head.target().ok_or(Error::Internal)?);
|
||||||
|
let mut arg_commit_count = vec!["rev-list".to_string(), "--count".to_string()];
|
||||||
let mut arg = vec![
|
let mut arg = vec![
|
||||||
"log".to_string(),
|
"log".to_string(),
|
||||||
"--pretty=tformat:".to_string(),
|
"--pretty=tformat:".to_string(),
|
||||||
@ -146,16 +96,18 @@ fn hoc(repo: &str, repo_dir: &str, cache_dir: &str) -> Result<(u64, String)> {
|
|||||||
];
|
];
|
||||||
let cache = CacheState::read_from_file(&cache_dir, &head)?;
|
let cache = CacheState::read_from_file(&cache_dir, &head)?;
|
||||||
match &cache {
|
match &cache {
|
||||||
CacheState::Current(res) => {
|
CacheState::Current { count, commits } => {
|
||||||
info!("Using cache for {}", repo_dir);
|
info!("Using cache for {}", repo_dir);
|
||||||
return Ok((*res, head));
|
return Ok((*count, head, *commits));
|
||||||
}
|
}
|
||||||
CacheState::Old(cache) => {
|
CacheState::Old(cache) => {
|
||||||
info!("Updating cache for {}", repo_dir);
|
info!("Updating cache for {}", repo_dir);
|
||||||
arg.push(format!("{}..HEAD", cache.head));
|
arg.push(format!("{}..HEAD", cache.head));
|
||||||
|
arg_commit_count.push(format!("{}..HEAD", cache.head));
|
||||||
}
|
}
|
||||||
CacheState::No => {
|
CacheState::No => {
|
||||||
info!("Creating cache for {}", repo_dir);
|
info!("Creating cache for {}", repo_dir);
|
||||||
|
arg_commit_count.push("HEAD".to_string());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
arg.push("--".to_string());
|
arg.push("--".to_string());
|
||||||
@ -166,6 +118,13 @@ fn hoc(repo: &str, repo_dir: &str, cache_dir: &str) -> Result<(u64, String)> {
|
|||||||
.output()?
|
.output()?
|
||||||
.stdout;
|
.stdout;
|
||||||
let output = String::from_utf8_lossy(&output);
|
let output = String::from_utf8_lossy(&output);
|
||||||
|
let output_commits = Command::new("git")
|
||||||
|
.args(&arg_commit_count)
|
||||||
|
.current_dir(&repo_dir)
|
||||||
|
.output()?
|
||||||
|
.stdout;
|
||||||
|
let output_commits = String::from_utf8_lossy(&output_commits);
|
||||||
|
let commits: u64 = output_commits.trim().parse()?;
|
||||||
let count: u64 = output
|
let count: u64 = output
|
||||||
.lines()
|
.lines()
|
||||||
.map(|s| {
|
.map(|s| {
|
||||||
@ -177,19 +136,24 @@ fn hoc(repo: &str, repo_dir: &str, cache_dir: &str) -> Result<(u64, String)> {
|
|||||||
})
|
})
|
||||||
.sum();
|
.sum();
|
||||||
|
|
||||||
let cache = cache.calculate_new_cache(count, (&head).into());
|
let cache = cache.calculate_new_cache(count, commits, (&head).into());
|
||||||
cache.write_to_file(cache_dir)?;
|
cache.write_to_file(cache_dir)?;
|
||||||
|
|
||||||
Ok((cache.count, head))
|
Ok((cache.count, head, commits))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remote_exists(url: &str) -> Result<bool> {
|
async fn remote_exists(url: &str) -> Result<bool> {
|
||||||
Ok(CLIENT.head(url).send()?.status() == reqwest::StatusCode::OK)
|
let resp = CLIENT.head(url).send().await?;
|
||||||
|
Ok(resp.status() == reqwest::StatusCode::OK)
|
||||||
|
|
||||||
|
// .map(|resp| resp.status() == reqwest::StatusCode::OK)
|
||||||
|
// .from_err()
|
||||||
}
|
}
|
||||||
|
|
||||||
enum HocResult {
|
enum HocResult {
|
||||||
Hoc {
|
Hoc {
|
||||||
hoc: u64,
|
hoc: u64,
|
||||||
|
commits: u64,
|
||||||
hoc_pretty: String,
|
hoc_pretty: String,
|
||||||
head: String,
|
head: String,
|
||||||
url: String,
|
url: String,
|
||||||
@ -199,7 +163,7 @@ enum HocResult {
|
|||||||
NotFound,
|
NotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_hoc_request<T, F>(
|
async fn handle_hoc_request<T, F>(
|
||||||
state: web::Data<Arc<State>>,
|
state: web::Data<Arc<State>>,
|
||||||
data: web::Path<(String, String)>,
|
data: web::Path<(String, String)>,
|
||||||
mapper: F,
|
mapper: F,
|
||||||
@ -208,51 +172,65 @@ where
|
|||||||
T: Service,
|
T: Service,
|
||||||
F: Fn(HocResult) -> Result<HttpResponse>,
|
F: Fn(HocResult) -> Result<HttpResponse>,
|
||||||
{
|
{
|
||||||
hoc_request::<T>(state, data).and_then(mapper)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn hoc_request<T: Service>(
|
|
||||||
state: web::Data<Arc<State>>,
|
|
||||||
data: web::Path<(String, String)>,
|
|
||||||
) -> Result<HocResult> {
|
|
||||||
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::domain(), repo);
|
let service_path = format!("{}/{}", T::domain(), repo);
|
||||||
let path = format!("{}/{}", state.repos, service_path);
|
let path = format!("{}/{}", state.repos, service_path);
|
||||||
let file = Path::new(&path);
|
|
||||||
let url = format!("https://{}", service_path);
|
let url = format!("https://{}", service_path);
|
||||||
|
let remote_exists = remote_exists(&url).await?;
|
||||||
|
let file = Path::new(&path);
|
||||||
if !file.exists() {
|
if !file.exists() {
|
||||||
if !remote_exists(&url)? {
|
if !remote_exists {
|
||||||
warn!("Repository does not exist: {}", url);
|
warn!("Repository does not exist: {}", url);
|
||||||
return Ok(HocResult::NotFound);
|
return mapper(HocResult::NotFound);
|
||||||
}
|
}
|
||||||
info!("Cloning {} for the first time", url);
|
info!("Cloning {} for the first time", url);
|
||||||
create_dir_all(file)?;
|
create_dir_all(file)?;
|
||||||
let repo = Repository::init_bare(file)?;
|
let repo = Repository::init_bare(file)?;
|
||||||
repo.remote_add_fetch("origin", "refs/heads/*:refs/heads/*")?;
|
repo.remote_add_fetch("origin", "refs/heads/*:refs/heads/*")?;
|
||||||
repo.remote_set_url("origin", &url)?;
|
repo.remote_set_url("origin", &url)?;
|
||||||
|
REPO_COUNT.fetch_add(1, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
pull(&path)?;
|
pull(&path)?;
|
||||||
let (hoc, head) = hoc(&service_path, &state.repos, &state.cache)?;
|
let (hoc, head, commits) = hoc(&service_path, &state.repos, &state.cache)?;
|
||||||
let hoc_pretty = match NumberPrefix::decimal(hoc as f64) {
|
let hoc_pretty = match NumberPrefix::decimal(hoc as f64) {
|
||||||
Standalone(hoc) => hoc.to_string(),
|
Standalone(hoc) => hoc.to_string(),
|
||||||
Prefixed(prefix, hoc) => format!("{:.1}{}", hoc, prefix),
|
Prefixed(prefix, hoc) => format!("{:.1}{}", hoc, prefix),
|
||||||
};
|
};
|
||||||
Ok(HocResult::Hoc {
|
let res = HocResult::Hoc {
|
||||||
hoc,
|
hoc,
|
||||||
|
commits,
|
||||||
hoc_pretty,
|
hoc_pretty,
|
||||||
head,
|
head,
|
||||||
url,
|
url,
|
||||||
repo,
|
repo,
|
||||||
service_path,
|
service_path,
|
||||||
})
|
};
|
||||||
|
mapper(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn json_hoc<T: Service>(
|
||||||
|
state: web::Data<Arc<State>>,
|
||||||
|
data: web::Path<(String, String)>,
|
||||||
|
) -> impl Future<Output = Result<HttpResponse>> {
|
||||||
|
let mapper = |r| match r {
|
||||||
|
HocResult::NotFound => p404(),
|
||||||
|
HocResult::Hoc {
|
||||||
|
hoc, head, commits, ..
|
||||||
|
} => Ok(HttpResponse::Ok().json(JsonResponse {
|
||||||
|
head: &head,
|
||||||
|
count: hoc,
|
||||||
|
commits,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
handle_hoc_request::<T, _>(state, data, mapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn calculate_hoc<T: Service>(
|
fn calculate_hoc<T: Service>(
|
||||||
state: web::Data<Arc<State>>,
|
state: web::Data<Arc<State>>,
|
||||||
data: web::Path<(String, String)>,
|
data: web::Path<(String, String)>,
|
||||||
) -> Result<HttpResponse> {
|
) -> impl Future<Output = Result<HttpResponse>> {
|
||||||
let mapper = |r| match r {
|
let mapper = move |r| match r {
|
||||||
HocResult::NotFound => Ok(p404()),
|
HocResult::NotFound => p404(),
|
||||||
HocResult::Hoc { hoc_pretty, .. } => {
|
HocResult::Hoc { hoc_pretty, .. } => {
|
||||||
let badge_opt = BadgeOptions {
|
let badge_opt = BadgeOptions {
|
||||||
subject: "Hits-of-Code".to_string(),
|
subject: "Hits-of-Code".to_string(),
|
||||||
@ -260,9 +238,8 @@ fn calculate_hoc<T: Service>(
|
|||||||
status: hoc_pretty,
|
status: hoc_pretty,
|
||||||
};
|
};
|
||||||
let badge = Badge::new(badge_opt)?;
|
let badge = Badge::new(badge_opt)?;
|
||||||
|
// TODO: remove clone
|
||||||
let (tx, rx_body) = mpsc::unbounded();
|
let body = badge.to_svg().as_bytes().to_vec();
|
||||||
let _ = tx.unbounded_send(Bytes::from(badge.to_svg().as_bytes()));
|
|
||||||
|
|
||||||
let expiration = SystemTime::now() + Duration::from_secs(30);
|
let expiration = SystemTime::now() + Duration::from_secs(30);
|
||||||
Ok(HttpResponse::Ok()
|
Ok(HttpResponse::Ok()
|
||||||
@ -274,7 +251,7 @@ fn calculate_hoc<T: Service>(
|
|||||||
CacheDirective::NoCache,
|
CacheDirective::NoCache,
|
||||||
CacheDirective::NoStore,
|
CacheDirective::NoStore,
|
||||||
]))
|
]))
|
||||||
.streaming(rx_body.map_err(|_| ErrorBadRequest("bad request"))))
|
.body(body))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
handle_hoc_request::<T, _>(state, data, mapper)
|
handle_hoc_request::<T, _>(state, data, mapper)
|
||||||
@ -283,11 +260,12 @@ fn calculate_hoc<T: Service>(
|
|||||||
fn overview<T: Service>(
|
fn overview<T: Service>(
|
||||||
state: web::Data<Arc<State>>,
|
state: web::Data<Arc<State>>,
|
||||||
data: web::Path<(String, String)>,
|
data: web::Path<(String, String)>,
|
||||||
) -> Result<HttpResponse> {
|
) -> impl Future<Output = Result<HttpResponse>> {
|
||||||
let mapper = |r| match r {
|
let mapper = |r| match r {
|
||||||
HocResult::NotFound => Ok(p404()),
|
HocResult::NotFound => p404(),
|
||||||
HocResult::Hoc {
|
HocResult::Hoc {
|
||||||
hoc,
|
hoc,
|
||||||
|
commits,
|
||||||
hoc_pretty,
|
hoc_pretty,
|
||||||
url,
|
url,
|
||||||
head,
|
head,
|
||||||
@ -295,60 +273,66 @@ fn overview<T: Service>(
|
|||||||
service_path,
|
service_path,
|
||||||
} => {
|
} => {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
|
let repo_info = RepoInfo {
|
||||||
|
commit_url: &T::commit_url(&repo, &head),
|
||||||
|
commits,
|
||||||
|
domain: &OPT.domain,
|
||||||
|
head: &head,
|
||||||
|
hoc,
|
||||||
|
hoc_pretty: &hoc_pretty,
|
||||||
|
path: &service_path,
|
||||||
|
url: &url,
|
||||||
|
};
|
||||||
templates::overview(
|
templates::overview(
|
||||||
&mut buf,
|
&mut buf,
|
||||||
VERSION_INFO,
|
VERSION_INFO,
|
||||||
&OPT.domain,
|
REPO_COUNT.load(Ordering::Relaxed),
|
||||||
&service_path,
|
repo_info,
|
||||||
&url,
|
|
||||||
hoc,
|
|
||||||
&hoc_pretty,
|
|
||||||
&head,
|
|
||||||
&T::commit_url(&repo, &head),
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let (tx, rx_body) = mpsc::unbounded();
|
Ok(HttpResponse::Ok().content_type("text/html").body(buf))
|
||||||
let _ = tx.unbounded_send(Bytes::from(buf));
|
|
||||||
|
|
||||||
Ok(HttpResponse::Ok()
|
|
||||||
.content_type("text/html")
|
|
||||||
.streaming(rx_body.map_err(|_| ErrorBadRequest("bad request"))))
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
handle_hoc_request::<T, _>(state, data, mapper)
|
handle_hoc_request::<T, _>(state, data, mapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
fn index() -> HttpResponse {
|
async fn index() -> Result<HttpResponse> {
|
||||||
HttpResponse::Ok()
|
let mut buf = Vec::new();
|
||||||
.content_type("text/html")
|
templates::index(
|
||||||
.body(INDEX.as_slice())
|
&mut buf,
|
||||||
|
VERSION_INFO,
|
||||||
|
REPO_COUNT.load(Ordering::Relaxed),
|
||||||
|
&OPT.domain,
|
||||||
|
)?;
|
||||||
|
Ok(HttpResponse::Ok().content_type("text/html").body(buf))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/generate")]
|
#[post("/generate")]
|
||||||
fn generate(params: web::Form<GeneratorForm>) -> Result<HttpResponse> {
|
async fn generate(params: web::Form<GeneratorForm<'_>>) -> Result<HttpResponse> {
|
||||||
let repo = format!("{}/{}", params.user, params.repo);
|
let repo = format!("{}/{}", params.user, params.repo);
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
templates::generate(
|
templates::generate(
|
||||||
&mut buf,
|
&mut buf,
|
||||||
VERSION_INFO,
|
VERSION_INFO,
|
||||||
|
REPO_COUNT.load(Ordering::Relaxed),
|
||||||
&OPT.domain,
|
&OPT.domain,
|
||||||
params.service.url(),
|
params.service.url(),
|
||||||
params.service.service(),
|
params.service.service(),
|
||||||
&repo,
|
&repo,
|
||||||
)?;
|
)?;
|
||||||
let (tx, rx_body) = mpsc::unbounded();
|
|
||||||
let _ = tx.unbounded_send(Bytes::from(buf));
|
|
||||||
|
|
||||||
Ok(HttpResponse::Ok()
|
Ok(HttpResponse::Ok().content_type("text/html").body(buf))
|
||||||
.content_type("text/html")
|
|
||||||
.streaming(rx_body.map_err(|_| ErrorBadRequest("bad request"))))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn p404() -> HttpResponse {
|
fn p404() -> Result<HttpResponse> {
|
||||||
HttpResponse::NotFound()
|
let mut buf = Vec::new();
|
||||||
.content_type("text/html")
|
templates::p404(&mut buf, VERSION_INFO, REPO_COUNT.load(Ordering::Relaxed))?;
|
||||||
.body(P404.as_slice())
|
Ok(HttpResponse::NotFound().content_type("text/html").body(buf))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn async_p404() -> Result<HttpResponse> {
|
||||||
|
p404()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/tacit-css.min.css")]
|
#[get("/tacit-css.min.css")]
|
||||||
@ -356,10 +340,12 @@ fn css() -> HttpResponse {
|
|||||||
HttpResponse::Ok().content_type("text/css").body(CSS)
|
HttpResponse::Ok().content_type("text/css").body(CSS)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> std::io::Result<()> {
|
#[get("/favicon.ico")]
|
||||||
std::env::set_var("RUST_LOG", "actix_web=info,hoc=info");
|
fn favicon32() -> HttpResponse {
|
||||||
pretty_env_logger::init();
|
HttpResponse::Ok().content_type("image/png").body(FAVICON)
|
||||||
openssl_probe::init_ssl_cert_env_vars();
|
}
|
||||||
|
|
||||||
|
async fn start_server() -> std::io::Result<()> {
|
||||||
let interface = format!("{}:{}", OPT.host, OPT.port);
|
let interface = format!("{}:{}", OPT.host, OPT.port);
|
||||||
let state = Arc::new(State {
|
let state = Arc::new(State {
|
||||||
repos: OPT.outdir.display().to_string(),
|
repos: OPT.outdir.display().to_string(),
|
||||||
@ -369,18 +355,30 @@ fn main() -> std::io::Result<()> {
|
|||||||
App::new()
|
App::new()
|
||||||
.data(state.clone())
|
.data(state.clone())
|
||||||
.wrap(middleware::Logger::default())
|
.wrap(middleware::Logger::default())
|
||||||
|
.wrap(middleware::NormalizePath)
|
||||||
.service(index)
|
.service(index)
|
||||||
.service(css)
|
.service(css)
|
||||||
|
.service(favicon32)
|
||||||
.service(generate)
|
.service(generate)
|
||||||
.service(web::resource("/github/{user}/{repo}").to(calculate_hoc::<GitHub>))
|
.service(web::resource("/github/{user}/{repo}").to(calculate_hoc::<GitHub>))
|
||||||
.service(web::resource("/gitlab/{user}/{repo}").to(calculate_hoc::<Gitlab>))
|
.service(web::resource("/gitlab/{user}/{repo}").to(calculate_hoc::<Gitlab>))
|
||||||
.service(web::resource("/bitbucket/{user}/{repo}").to(calculate_hoc::<Bitbucket>))
|
.service(web::resource("/bitbucket/{user}/{repo}").to(calculate_hoc::<Bitbucket>))
|
||||||
|
.service(web::resource("/github/{user}/{repo}/json").to(json_hoc::<GitHub>))
|
||||||
|
.service(web::resource("/gitlab/{user}/{repo}/json").to(json_hoc::<Gitlab>))
|
||||||
|
.service(web::resource("/bitbucket/{user}/{repo}/json").to(json_hoc::<Bitbucket>))
|
||||||
.service(web::resource("/view/github/{user}/{repo}").to(overview::<GitHub>))
|
.service(web::resource("/view/github/{user}/{repo}").to(overview::<GitHub>))
|
||||||
.service(web::resource("/view/gitlab/{user}/{repo}").to(overview::<Gitlab>))
|
.service(web::resource("/view/gitlab/{user}/{repo}").to(overview::<Gitlab>))
|
||||||
.service(web::resource("/view/bitbucket/{user}/{repo}").to(overview::<Bitbucket>))
|
.service(web::resource("/view/bitbucket/{user}/{repo}").to(overview::<Bitbucket>))
|
||||||
.default_service(web::resource("").route(web::get().to(p404)))
|
.default_service(web::resource("").route(web::get().to(async_p404)))
|
||||||
})
|
})
|
||||||
.workers(OPT.workers)
|
.workers(OPT.workers)
|
||||||
.bind(interface)?
|
.bind(interface)?
|
||||||
.run()
|
.run()
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
|
config::init().await.unwrap();
|
||||||
|
start_server().await
|
||||||
}
|
}
|
||||||
|
22
src/statics.rs
Normal file
22
src/statics.rs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
use crate::{config::Opt, count::count_repositories};
|
||||||
|
use std::sync::atomic::AtomicUsize;
|
||||||
|
use structopt::StructOpt;
|
||||||
|
|
||||||
|
pub struct VersionInfo<'a> {
|
||||||
|
pub commit: &'a str,
|
||||||
|
pub version: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) const VERSION_INFO: VersionInfo = VersionInfo {
|
||||||
|
commit: env!("VERGEN_SHA_SHORT"),
|
||||||
|
version: env!("CARGO_PKG_VERSION"),
|
||||||
|
};
|
||||||
|
pub(crate) const CSS: &str = include_str!("../static/tacit-css.min.css");
|
||||||
|
pub(crate) const FAVICON: &[u8] = include_bytes!("../static/favicon32.png");
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
pub(crate) static ref CLIENT: reqwest::Client = reqwest::Client::new();
|
||||||
|
pub(crate) static ref OPT: Opt = Opt::from_args();
|
||||||
|
pub(crate) static ref REPO_COUNT: AtomicUsize =
|
||||||
|
AtomicUsize::new(count_repositories(&OPT.outdir).unwrap());
|
||||||
|
}
|
10
src/template.rs
Normal file
10
src/template.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
pub struct RepoInfo<'a> {
|
||||||
|
pub commit_url: &'a str,
|
||||||
|
pub commits: u64,
|
||||||
|
pub domain: &'a str,
|
||||||
|
pub head: &'a str,
|
||||||
|
pub hoc: u64,
|
||||||
|
pub hoc_pretty: &'a str,
|
||||||
|
pub path: &'a str,
|
||||||
|
pub url: &'a str,
|
||||||
|
}
|
BIN
static/favicon32.png
Normal file
BIN
static/favicon32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 983 B |
@ -1,6 +1,6 @@
|
|||||||
@use crate::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(title: &str, header: &str, content: Content, version_info: VersionInfo)
|
@(title: &str, header: &str, content: Content, version_info: VersionInfo, repo_count: usize)
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
@ -38,6 +38,13 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<small>Currently serving @repo_count repositories</small>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li><small><a href="https://github.com/vbrandl/hoc">GitHub</a></small></li>
|
<li><small><a href="https://github.com/vbrandl/hoc">GitHub</a></small></li>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@use super::base;
|
@use super::base;
|
||||||
@use crate::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, domain: &str, url: &str, service: &str, path: &str)
|
@(version_info: VersionInfo, repo_count: usize, domain: &str, url: &str, service: &str, path: &str)
|
||||||
|
|
||||||
@:base("Hits-of-Code Badges", "Badge Generator", {
|
@:base("Hits-of-Code Badges", "Badge Generator", {
|
||||||
|
|
||||||
@ -20,4 +20,4 @@ It will be rendered like this
|
|||||||
<pre>
|
<pre>
|
||||||
<a href="https://@domain/view/@service/@path"><img src="https://@domain/@service/@path" alt="example badge" /></a>
|
<a href="https://@domain/view/@service/@path"><img src="https://@domain/@service/@path" alt="example badge" /></a>
|
||||||
</pre>
|
</pre>
|
||||||
}, version_info)
|
}, version_info, repo_count)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@use super::base;
|
@use super::base;
|
||||||
@use crate::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, domain: &str)
|
@(version_info: VersionInfo, repo_count: usize, domain: &str)
|
||||||
|
|
||||||
@:base("Hits-of-Code Badges", "Hits-of-Code Badges", {
|
@:base("Hits-of-Code Badges", "Hits-of-Code Badges", {
|
||||||
|
|
||||||
@ -45,6 +45,22 @@ would render this badge:
|
|||||||
alt="example badge" /></a>
|
alt="example badge" /></a>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
You can also request the HoC as JSON by appending <code>/json</code> to the request path. This will return a JSON object
|
||||||
|
with three fields: <code>count</code> (the HoC value), <code>commits</code> (the number of commits) and
|
||||||
|
<code>head</code> (the commit ref of HEAD). Requesting <a
|
||||||
|
href="https://@domain/github/vbrandl/hoc/json">https://@domain/github/vbrandl/hoc/json</a> might return something along
|
||||||
|
the lines of
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
{
|
||||||
|
"head": "1f01c3b964b018fb0c0c2c5b572bf4ace2968546",
|
||||||
|
"count": 8324,
|
||||||
|
"commits": 223
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
|
||||||
<h2>Badge Generator</h2>
|
<h2>Badge Generator</h2>
|
||||||
|
|
||||||
<form method="post" action="/generate">
|
<form method="post" action="/generate">
|
||||||
@ -76,4 +92,4 @@ my <a href="https://mirror.oldsql.cc/key.asc">GPG key</a>
|
|||||||
(<a href="http://pool.sks-keyservers.net/pks/lookup?op=get&search=0x1FFE431282F4B8CC0A7579167FB009175885FC76">from a
|
(<a href="http://pool.sks-keyservers.net/pks/lookup?op=get&search=0x1FFE431282F4B8CC0A7579167FB009175885FC76">from a
|
||||||
keyserver</a>), or by using any other UID from my key.
|
keyserver</a>), or by using any other UID from my key.
|
||||||
</p>
|
</p>
|
||||||
}, version_info)
|
}, version_info, repo_count)
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
@use super::base;
|
@use super::base;
|
||||||
@use crate::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
@use crate::template::RepoInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, domain: &str, path: &str, url: &str, hoc: u64, hoc_pretty: &str, head: &str, commit_url: &str)
|
@(version_info: VersionInfo, repo_count: usize, repo_info: RepoInfo)
|
||||||
|
|
||||||
@:base("Hits-of-Code Badges", "Overview", {
|
@:base("Hits-of-Code Badges", "Overview", {
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The project <a href="@url">@url</a> has <strong>@hoc_pretty</strong> (exactly @hoc) hits of code at <a href="@commit_url">@head</a>.
|
The project <a href="@repo_info.url">@repo_info.url</a> has
|
||||||
|
<strong>@repo_info.hoc_pretty</strong> (exactly @repo_info.hoc) hits of code at
|
||||||
|
<a href="@repo_info.commit_url">@repo_info.head</a>. The repository contains
|
||||||
|
<strong>@repo_info.commits</strong> commits.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -14,6 +18,6 @@ To include the badge in your readme, use the following markdown:
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
[](https://@domain/view/@path)
|
[](https://@repo_info.domain/view/@repo_info.path)
|
||||||
</pre>
|
</pre>
|
||||||
}, version_info)
|
}, version_info, repo_count)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@use super::base;
|
@use super::base;
|
||||||
@use crate::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo)
|
@(version_info: VersionInfo, repo_count: usize)
|
||||||
|
|
||||||
@:base("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>
|
||||||
@ -11,4 +11,4 @@
|
|||||||
<p>
|
<p>
|
||||||
If you think, this is a mistake on my side, please <a href="mailto:mail+hoc@@vbrandl.net">drop me a mail</a>.
|
If you think, this is a mistake on my side, please <a href="mailto:mail+hoc@@vbrandl.net">drop me a mail</a>.
|
||||||
</p>
|
</p>
|
||||||
}, version_info)
|
}, version_info, repo_count)
|
||||||
|
16
templates/p404_no_master.rs.html
Normal file
16
templates/p404_no_master.rs.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
@use super::base;
|
||||||
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
|
@(version_info: VersionInfo, repo_count: usize)
|
||||||
|
|
||||||
|
@:base("Master Branch not Found - Hits-of-Code Badges", "404 - Master Branch not Found", {
|
||||||
|
<p>
|
||||||
|
<big>Sorry</big>. I couldn't find the master branch of your repositroy.
|
||||||
|
Currently this service depends on the existence of a master branch. Please go
|
||||||
|
<a href="/">back to the homepage</a>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If you think, this is a mistake on my side, please <a href="mailto:mail+hoc@@vbrandl.net">drop me a mail</a>.
|
||||||
|
</p>
|
||||||
|
}, version_info, repo_count)
|
@ -1,7 +1,7 @@
|
|||||||
@use super::base;
|
@use super::base;
|
||||||
@use crate::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo)
|
@(version_info: VersionInfo, repo_count: usize)
|
||||||
|
|
||||||
@:base("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>
|
||||||
@ -11,4 +11,4 @@
|
|||||||
<p>
|
<p>
|
||||||
If you think, this is a bug, please <a href="mailto:mail+hoc@@vbrandl.net">drop me a mail</a>.
|
If you think, this is a bug, please <a href="mailto:mail+hoc@@vbrandl.net">drop me a mail</a>.
|
||||||
</p>
|
</p>
|
||||||
}, version_info)
|
}, version_info, repo_count)
|
||||||
|
Reference in New Issue
Block a user