Compare commits

...

60 Commits

Author SHA1 Message Date
9900518d62 Bump version (v0.19.0)
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2021-09-03 13:35:45 +02:00
d37f5ba32b Merge pull request #330 from vbrandl/chore/update-actix-web2
Update actix-web and tokio
2021-09-03 13:20:09 +02:00
bcb5650cc9 Update actix-web and tokio
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-03 13:13:03 +02:00
dff8151938 Merge branch 'master' of github.com:vbrandl/hoc
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-03 12:09:30 +02:00
9d71ef14fc Merge pull request #328 from vbrandl/dependabot/cargo/bytes-1.1.0
Bump bytes from 1.0.1 to 1.1.0
2021-09-03 12:09:24 +02:00
888e85b1f4 Mention sourcehut in readme 2021-09-03 12:04:38 +02:00
73e0bfad92 Bump bytes from 1.0.1 to 1.1.0
Bumps [bytes](https://github.com/tokio-rs/bytes) from 1.0.1 to 1.1.0.
- [Release notes](https://github.com/tokio-rs/bytes/releases)
- [Changelog](https://github.com/tokio-rs/bytes/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/bytes/compare/v1.0.1...v1.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-03 10:00:46 +00:00
ae4266044b Merge pull request #314 from vbrandl/dependabot/cargo/vergen-5.1.15
All checks were successful
continuous-integration/drone/push Build is passing
Bump vergen from 5.1.13 to 5.1.15
2021-09-03 12:00:45 +02:00
c5bae481da Merge pull request #317 from vbrandl/dependabot/cargo/git2-0.13.21
Bump git2 from 0.13.20 to 0.13.21
2021-09-03 12:00:34 +02:00
d71656295f Merge pull request #319 from vbrandl/dependabot/cargo/tracing-subscriber-0.2.20
Bump tracing-subscriber from 0.2.19 to 0.2.20
2021-09-03 12:00:23 +02:00
565a2e3129 Merge pull request #321 from vbrandl/dependabot/cargo/tracing-bunyan-formatter-0.2.5
Bump tracing-bunyan-formatter from 0.2.4 to 0.2.5
2021-09-03 12:00:12 +02:00
e2da36d2e9 Merge pull request #324 from vbrandl/dependabot/cargo/serde_json-1.0.67
Bump serde_json from 1.0.64 to 1.0.67
2021-09-03 12:00:03 +02:00
ad770f71ec Merge pull request #325 from vbrandl/dependabot/cargo/serde-1.0.130
Bump serde from 1.0.126 to 1.0.130
2021-09-03 11:59:46 +02:00
f6d47baefd Bump version (v0.18.0) 2021-09-03 11:45:10 +02:00
44d47b1d5f Implement badges for sourcehut 2021-09-03 11:44:22 +02:00
f87b6ee8f4 Bump serde from 1.0.126 to 1.0.130
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.126 to 1.0.130.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.126...v1.0.130)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-30 04:21:03 +00:00
6322e6e7e3 Bump serde_json from 1.0.64 to 1.0.67
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.64 to 1.0.67.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.64...v1.0.67)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-30 04:20:56 +00:00
39592effd2 Bump tracing-bunyan-formatter from 0.2.4 to 0.2.5
Bumps [tracing-bunyan-formatter](https://github.com/LukeMathWalker/tracing-bunyan-formatter) from 0.2.4 to 0.2.5.
- [Release notes](https://github.com/LukeMathWalker/tracing-bunyan-formatter/releases)
- [Commits](https://github.com/LukeMathWalker/tracing-bunyan-formatter/compare/v0.2.4...v0.2.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-23 04:23:35 +00:00
632638ddd8 Bump tracing-subscriber from 0.2.19 to 0.2.20
Bumps [tracing-subscriber](https://github.com/tokio-rs/tracing) from 0.2.19 to 0.2.20.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-subscriber-0.2.19...tracing-subscriber-0.2.20)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-18 04:20:08 +00:00
c4e31f2f67 Bump git2 from 0.13.20 to 0.13.21
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.13.20 to 0.13.21.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/0.13.20...0.13.21)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-13 04:22:12 +00:00
46d7ae030e Bump vergen from 5.1.13 to 5.1.15
Bumps [vergen](https://github.com/rustyhorde/vergen) from 5.1.13 to 5.1.15.
- [Release notes](https://github.com/rustyhorde/vergen/releases)
- [Commits](https://github.com/rustyhorde/vergen/compare/5.1.13...5.1.15)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-06 04:21:48 +00:00
3a57fcca9d Merge pull request #305 from vbrandl/dependabot/cargo/vergen-5.1.13
Bump vergen from 5.1.2 to 5.1.13
2021-07-16 09:03:52 +02:00
3051bdc0c7 Bump vergen from 5.1.2 to 5.1.13
Bumps [vergen](https://github.com/rustyhorde/vergen) from 5.1.2 to 5.1.13.
- [Release notes](https://github.com/rustyhorde/vergen/releases)
- [Commits](https://github.com/rustyhorde/vergen/compare/5.1.2...5.1.13)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-13 04:20:01 +00:00
e267a4fc8a chore: Bump version (v0.17.4)
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build is failing
2021-06-29 19:47:08 +02:00
441ab76ca6 Merge pull request #300 from vbrandl/revert-299-dependabot/cargo/vergen-5.1.10
Revert "Bump vergen from 5.1.2 to 5.1.10"
2021-06-29 19:46:36 +02:00
155d79a019 Revert "Bump vergen from 5.1.2 to 5.1.10" 2021-06-29 19:46:21 +02:00
1fe39fbd3c fix(docker): Start with lib project for caching
Some checks failed
continuous-integration/drone/tag Build is passing
continuous-integration/drone/push Build is failing
2021-06-29 19:23:34 +02:00
1fae322993 fix(docker): Start with lib project for caching
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build is failing
2021-06-29 19:14:51 +02:00
13c193d04a chore: Bump version (v0.17.3)
Some checks failed
continuous-integration/drone/push Build is failing
2021-06-29 19:06:35 +02:00
701299ab5b Merge pull request #299 from vbrandl/dependabot/cargo/vergen-5.1.10
Bump vergen from 5.1.2 to 5.1.10
2021-06-29 19:01:27 +02:00
2277931d3c Merge pull request #291 from vbrandl/dependabot/cargo/git2-0.13.20
Bump git2 from 0.13.18 to 0.13.20
2021-06-29 18:57:39 +02:00
6c59acc0ab Bump vergen from 5.1.2 to 5.1.10
Bumps [vergen](https://github.com/rustyhorde/vergen) from 5.1.2 to 5.1.10.
- [Release notes](https://github.com/rustyhorde/vergen/releases)
- [Commits](https://github.com/rustyhorde/vergen/compare/5.1.2...5.1.10)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-29 16:56:16 +00:00
79d947fb36 Merge pull request #297 from vbrandl/dependabot/cargo/tracing-subscriber-0.2.19
Bump tracing-subscriber from 0.2.18 to 0.2.19
2021-06-29 18:55:39 +02:00
a1133259c2 Merge pull request #298 from vbrandl/dependabot/cargo/ructe-0.13.4
Bump ructe from 0.13.2 to 0.13.4
2021-06-29 18:55:05 +02:00
9eb47bd94b Bump ructe from 0.13.2 to 0.13.4
Bumps [ructe](https://github.com/kaj/ructe) from 0.13.2 to 0.13.4.
- [Release notes](https://github.com/kaj/ructe/releases)
- [Changelog](https://github.com/kaj/ructe/blob/master/CHANGELOG.md)
- [Commits](https://github.com/kaj/ructe/compare/v0.13.2...v0.13.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-28 04:24:35 +00:00
8f6c52a6f5 Bump tracing-subscriber from 0.2.18 to 0.2.19
Bumps [tracing-subscriber](https://github.com/tokio-rs/tracing) from 0.2.18 to 0.2.19.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-subscriber-0.2.18...tracing-subscriber-0.2.19)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-28 04:24:28 +00:00
b50112c7c0 Bump git2 from 0.13.18 to 0.13.20
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.13.18 to 0.13.20.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/0.13.18...0.13.20)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-11 04:12:07 +00:00
62c80a81de Change link to gpg key 2021-06-10 12:10:00 +02:00
04f1437d0c chores(cargo): Bump version (0.17.2) 2021-05-27 13:18:31 +02:00
e706176d84 Merge pull request #282 from vbrandl/dependabot/cargo/serde-1.0.126
Bump serde from 1.0.125 to 1.0.126
2021-05-27 12:55:05 +02:00
a2a0047e03 Merge pull request #283 from vbrandl/dependabot/cargo/futures-0.3.15
Bump futures from 0.3.14 to 0.3.15
2021-05-27 12:54:37 +02:00
be7320e24e Merge pull request #281 from vbrandl/dependabot/cargo/tracing-bunyan-formatter-0.2.4
Bump tracing-bunyan-formatter from 0.2.0 to 0.2.4
2021-05-27 12:54:27 +02:00
55f937aac2 Bump tracing-bunyan-formatter from 0.2.0 to 0.2.4
Bumps [tracing-bunyan-formatter](https://github.com/LukeMathWalker/tracing-bunyan-formatter) from 0.2.0 to 0.2.4.
- [Release notes](https://github.com/LukeMathWalker/tracing-bunyan-formatter/releases)
- [Commits](https://github.com/LukeMathWalker/tracing-bunyan-formatter/compare/v0.2.0...v0.2.4)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-27 10:48:45 +00:00
d929a559b6 Bump futures from 0.3.14 to 0.3.15
Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.14 to 0.3.15.
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.14...0.3.15)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-27 10:48:26 +00:00
5e7374deea Bump serde from 1.0.125 to 1.0.126
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.125 to 1.0.126.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.125...v1.0.126)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-27 10:48:22 +00:00
0821559471 Remove reviewer and ignored dependencies for dependabot 2021-05-27 12:47:10 +02:00
a9ede0b2c7 Merge pull request #273 from vbrandl/dependabot/cargo/openssl-probe-0.1.4
Bump openssl-probe from 0.1.2 to 0.1.4
2021-05-27 12:45:28 +02:00
be48ebd2d9 Fix clippy lint 2021-05-27 12:39:45 +02:00
c80bef7cbd Merge pull request #271 from vbrandl/dependabot/cargo/tracing-subscriber-0.2.18
Bump tracing-subscriber from 0.2.17 to 0.2.18
2021-05-27 12:20:35 +02:00
c9b67eb6e6 Merge pull request #270 from vbrandl/dependabot/cargo/tracing-0.1.26
Bump tracing from 0.1.25 to 0.1.26
2021-05-27 12:19:55 +02:00
1ab4cb6c71 Merge pull request #268 from vbrandl/dependabot/add-v2-config-file
Upgrade to GitHub-native Dependabot
2021-05-27 12:18:35 +02:00
9785b38ce0 Bump openssl-probe from 0.1.2 to 0.1.4
Bumps [openssl-probe](https://github.com/alexcrichton/openssl-probe) from 0.1.2 to 0.1.4.
- [Release notes](https://github.com/alexcrichton/openssl-probe/releases)
- [Commits](https://github.com/alexcrichton/openssl-probe/compare/0.1.2...0.1.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-05-12 04:20:25 +00:00
492e17b997 Bump tracing-subscriber from 0.2.17 to 0.2.18
Bumps [tracing-subscriber](https://github.com/tokio-rs/tracing) from 0.2.17 to 0.2.18.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-subscriber-0.2.17...tracing-subscriber-0.2.18)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-05-03 04:19:29 +00:00
43586e534b Bump tracing from 0.1.25 to 0.1.26
Bumps [tracing](https://github.com/tokio-rs/tracing) from 0.1.25 to 0.1.26.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-0.1.25...tracing-0.1.26)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-05-03 04:19:05 +00:00
70bca967f3 Upgrade to GitHub-native Dependabot 2021-04-29 15:09:17 +00:00
61013e43ab Merge pull request #264 from vbrandl/dependabot/cargo/git2-0.13.18
Some checks failed
continuous-integration/drone/push Build is failing
Bump git2 from 0.13.17 to 0.13.18
2021-04-23 12:52:03 +02:00
0c100e76ad Merge pull request #263 from vbrandl/dependabot/cargo/vergen-5.1.2
Bump vergen from 5.1.1 to 5.1.2
2021-04-23 12:51:30 +02:00
000c7457f5 Bump git2 from 0.13.17 to 0.13.18
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.13.17 to 0.13.18.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/0.13.17...0.13.18)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-20 04:19:33 +00:00
70361e8b70 Bump vergen from 5.1.1 to 5.1.2
Bumps [vergen](https://github.com/rustyhorde/vergen) from 5.1.1 to 5.1.2.
- [Release notes](https://github.com/rustyhorde/vergen/releases)
- [Commits](https://github.com/rustyhorde/vergen/compare/5.1.1...5.1.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-20 04:19:12 +00:00
4237f6cc06 Merge pull request #262 from vbrandl/disable-gitlab-ci
Some checks failed
continuous-integration/drone/push Build is failing
Remove `.gitlab-ci.yml`
2021-04-19 09:02:03 +02:00
13 changed files with 388 additions and 756 deletions

10
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: daily
time: "04:00"
open-pull-requests-limit: 10
assignees:
- vbrandl

1022
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package]
name = "hoc"
version = "0.17.1"
version = "0.19.0"
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
edition = "2018"
build = "build.rs"
@ -13,33 +13,34 @@ path = "src/main.rs"
name = "hoc"
[dependencies]
actix-rt = "1.1.1"
actix-web = "3.3.2"
actix-rt = "2.2.0"
actix-web = "4.0.0-beta.8"
badge = "0.3.0"
bytes = "1.0.1"
bytes = "1.1.0"
config = { version = "0.11.0", features = ["toml"] }
dotenv = "0.15.0"
futures = "0.3.14"
git2 = "0.13.17"
futures = "0.3.17"
git2 = "0.13.21"
lazy_static = "1.4.0"
number_prefix = "0.4.0"
openssl-probe = "0.1.2"
reqwest = "0.10.10"
serde = "1.0.125"
openssl-probe = "0.1.4"
reqwest = "0.11.4"
serde = "1.0.130"
serde_derive = "1.0.123"
serde_json = "1.0.64"
tracing = "0.1.25"
tracing-actix-web = "0.2.1"
tracing-bunyan-formatter = "0.2.0"
serde_json = "1.0.67"
tracing = "0.1.26"
tracing-actix-web = "0.4.0-beta.11"
tracing-bunyan-formatter = "0.2.5"
tracing-futures = "0.2.5"
tracing-log = "0.1.2"
tracing-subscriber = { version = "0.2.17", features = ["registry", "env-filter"] }
tracing-subscriber = { version = "0.2.20", features = ["registry", "env-filter"] }
[build-dependencies]
ructe = "0.13.2"
vergen = { version = "5.1.1", default-features = false, features = ["git"] }
ructe = "0.13.4"
vergen = { version = "5.1.15", default-features = false, features = ["git"] }
[dev-dependencies]
ructe = "0.13.2"
awc = "3.0.0-beta.7"
ructe = "0.13.4"
tempfile = "3.2.0"
tokio = "0.2.25"
tokio = "1.11.0"

View File

@ -1,7 +1,8 @@
FROM ekidd/rust-musl-builder:stable as builder
# create new cargo project
RUN USER=rust cargo init --bin
RUN USER=rust cargo init --lib
RUN echo 'fn main() { println!("Hello, world!"); }' >> src/main.rs
# copy build config
COPY --chown=rust ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml

View File

@ -19,8 +19,8 @@ The API is as simple as
https://<host>/<service>/<user>/<repo>
```
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:
where `<service>` is one of `gitub`, `gitlab`, `bitbucket` or `sourcehut`. The HoC data can also be received as JSON by
appending `/json` to the reuqest path:
```
https://<host>/<service>/<user>/<repo>/json

View File

@ -101,9 +101,9 @@ impl<'a> CacheState<'a> {
entries.insert(
branch.into(),
CacheEntry {
commits,
head,
count,
commits,
},
);
Cache { entries }

View File

@ -22,14 +22,14 @@ use crate::{
cache::CacheState,
config::Settings,
error::{Error, Result},
service::{Bitbucket, FormService, GitHub, Gitlab, Service},
service::{Bitbucket, FormService, GitHub, Gitlab, Service, Sourcehut},
statics::{CLIENT, CSS, FAVICON, VERSION_INFO},
template::RepoInfo,
};
use actix_web::{
dev::Server,
http::header::{CacheControl, CacheDirective, Expires, LOCATION},
middleware::{self, normalize::TrailingSlash},
middleware::{self, TrailingSlash},
web, App, HttpResponse, HttpServer, Responder,
};
use badge::{Badge, BadgeOptions};
@ -224,10 +224,10 @@ where
})?;
repo_count.fetch_sub(1, Ordering::Relaxed);
Ok(HttpResponse::TemporaryRedirect()
.header(
.insert_header((
LOCATION,
format!("/{}/{}/{}/view", T::url_path(), data.0, data.1),
)
))
.finish())
};
future.instrument(span).await
@ -318,8 +318,8 @@ fn no_cache_response(body: Vec<u8>) -> HttpResponse {
let expiration = SystemTime::now() + Duration::from_secs(30);
HttpResponse::Ok()
.content_type("image/svg+xml")
.set(Expires(expiration.into()))
.set(CacheControl(vec![
.insert_header(Expires(expiration.into()))
.insert_header(CacheControl(vec![
CacheDirective::MaxAge(0u32),
CacheDirective::MustRevalidate,
CacheDirective::NoCache,
@ -480,7 +480,7 @@ async fn start_server(listener: TcpListener, settings: Settings) -> std::io::Res
App::new()
.app_data(state.clone())
.app_data(repo_count.clone())
.wrap(tracing_actix_web::TracingLogger)
.wrap(tracing_actix_web::TracingLogger::default())
.wrap(middleware::NormalizePath::new(TrailingSlash::Trim))
.service(index)
.service(health_check)
@ -490,6 +490,7 @@ async fn start_server(listener: TcpListener, settings: Settings) -> std::io::Res
.service(web::resource("/github/{user}/{repo}").to(calculate_hoc::<GitHub>))
.service(web::resource("/gitlab/{user}/{repo}").to(calculate_hoc::<Gitlab>))
.service(web::resource("/bitbucket/{user}/{repo}").to(calculate_hoc::<Bitbucket>))
.service(web::resource("/sourcehut/{user}/{repo}").to(calculate_hoc::<Sourcehut>))
.service(
web::resource("/github/{user}/{repo}/delete")
.route(web::post().to(delete_repo_and_cache::<GitHub>)),
@ -502,16 +503,22 @@ async fn start_server(listener: TcpListener, settings: Settings) -> std::io::Res
web::resource("/bitbucket/{user}/{repo}/delete")
.route(web::post().to(delete_repo_and_cache::<Bitbucket>)),
)
.service(
web::resource("/sourcehut/{user}/{repo}/delete")
.route(web::post().to(delete_repo_and_cache::<Sourcehut>)),
)
.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("/sourcehut/{user}/{repo}/json").to(json_hoc::<Sourcehut>))
.service(web::resource("/view/github/{user}/{repo}").to(overview::<GitHub>))
.service(web::resource("/view/gitlab/{user}/{repo}").to(overview::<Gitlab>))
.service(web::resource("/view/bitbucket/{user}/{repo}").to(overview::<Bitbucket>))
.service(web::resource("/github/{user}/{repo}/view").to(overview::<GitHub>))
.service(web::resource("/gitlab/{user}/{repo}/view").to(overview::<Gitlab>))
.service(web::resource("/bitbucket/{user}/{repo}/view").to(overview::<Bitbucket>))
.default_service(web::resource("").route(web::get().to(async_p404)))
.service(web::resource("/sourcehut/{user}/{repo}/view").to(overview::<Sourcehut>))
.default_service(web::to(async_p404))
})
.workers(workers)
.listen(listener)?

View File

@ -12,6 +12,8 @@ pub(crate) enum FormService {
Gitlab,
#[serde(rename = "bitbucket")]
Bitbucket,
#[serde(rename = "sourcehut")]
Sourcehut,
}
impl FormService {
@ -20,6 +22,7 @@ impl FormService {
FormService::GitHub => "github.com",
FormService::Gitlab => "gitlab.com",
FormService::Bitbucket => "bitbucket.org",
FormService::Sourcehut => "git.sr.ht",
}
}
@ -28,6 +31,7 @@ impl FormService {
FormService::GitHub => "github",
FormService::Gitlab => "gitlab",
FormService::Bitbucket => "bitbucket",
FormService::Sourcehut => "sourcehut",
}
}
}
@ -73,3 +77,17 @@ impl Service for Bitbucket {
format!("https://{}/{}/commits/{}", Self::domain(), repo, commit_ref)
}
}
pub(crate) struct Sourcehut;
impl Service for Sourcehut {
fn domain() -> &'static str {
"git.sr.ht"
}
fn url_path() -> &'static str {
"sourcehut"
}
fn commit_url(repo: &str, commit_ref: &str) -> String {
format!("https://{}/{}/commit/{}", Self::domain(), repo, commit_ref)
}
}

View File

@ -20,7 +20,7 @@ gives an overview about the amount of work put into a codebase.
<p>
There is a <a href="https://github.com/yegor256/hoc/">command-line tool</a> to calculate the HoC of a repository, but
some people might want a nice badge to put in their README, that's why I implemented this API. Currently the API can be
used for GitHub, GitLab and Bitbucket repositories. Just put the following code in your README:
used for GitHub, GitLab, Bitbucket and Sourcehut repositories. Just put the following code in your README:
</p>
<pre>
@ -28,8 +28,8 @@ used for GitHub, GitLab and Bitbucket repositories. Just put the following code
</pre>
<p>
where <code>&lt;service&gt;</code> is one of <code>github</code>, <code>gitlab</code> or <code>bitbucket</code>. So the
following Markdown
where <code>&lt;service&gt;</code> is one of <code>github</code>, <code>gitlab</code>, <code>bitbucket</code> or
<code>sourcehut</code>. So the following Markdown
</p>
<pre>
@ -74,6 +74,7 @@ the lines of
<option value="github">GitHub</option>
<option value="gitlab">Gitlab</option>
<option value="bitbucket">Bitbucket</option>
<option value="sourcehut">Sourcehut</option>
</select>
<label>/</label>
<input name="user" id="user" type="text" placeholder="user" />
@ -94,7 +95,7 @@ welcome.
<p>
You can reach me via mail: <a href="mailto:mail+hoc@@vbrandl.net">mail+hoc@@vbrandl.net</a> preferably using
my <a href="https://mirror.oldsql.cc/key.asc">GPG key</a>
my <a href="https://www.vbrandl.net/static/keys/0x1FFE431282F4B8CC0A7579167FB009175885FC76.asc">GPG key</a>
(<a href="http://pool.sks-keyservers.net/pks/lookup?op=get&amp;search=0x1FFE431282F4B8CC0A7579167FB009175885FC76">from a
keyserver</a>), or by using any other UID from my key.
</p>

View File

@ -1,12 +1,10 @@
mod util;
use actix_web::client;
#[actix_rt::test]
async fn badge_succeeds() {
let test_app = util::spawn_app().await;
let client = client::Client::default();
let client = awc::Client::default();
let response = client
.get(&format!("{}/github/vbrandl/hoc", test_app.address))

View File

@ -1,12 +1,10 @@
mod util;
use actix_web::client;
#[actix_rt::test]
async fn health_check_works() {
let test_app = util::spawn_app().await;
let client = client::Client::default();
let client = awc::Client::default();
let response = client
.get(&format!("{}/health_check", test_app.address))

View File

@ -1,12 +1,10 @@
mod util;
use actix_web::client;
#[actix_rt::test]
async fn index_returns_success() {
let test_app = util::spawn_app().await;
let client = client::Client::default();
let client = awc::Client::default();
let response = client
.get(&format!("{}/", test_app.address))

View File

@ -1,12 +1,10 @@
mod util;
use actix_web::client;
#[actix_rt::test]
async fn json_returns_success() {
let test_app = util::spawn_app().await;
let client = client::Client::default();
let client = awc::Client::default();
let response = client
.get(&format!("{}/github/vbrandl/hoc/json", test_app.address))