Compare commits
43 Commits
v0.10.1
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
bdae157caf | |||
d6618a0e61 | |||
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 |
15
.github/workflows/rust.yml
vendored
Normal file
15
.github/workflows/rust.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
name: Rust
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Build
|
||||
run: cargo build --verbose
|
||||
- name: Run tests
|
||||
run: cargo test --verbose
|
@ -1,6 +1,6 @@
|
||||
image: docker:stable
|
||||
image: docker:19.03
|
||||
services:
|
||||
- docker:dind
|
||||
- docker:19.03-dind
|
||||
|
||||
stages:
|
||||
- build
|
||||
@ -9,6 +9,8 @@ stages:
|
||||
variables:
|
||||
DOCKER_HOST: tcp://docker:2375
|
||||
DOCKER_DRIVER: overlay2
|
||||
# DOCKER_TLS_CERTDIR: "/certs"
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
CONTAINER_BUILDER_IMAGE: $CI_REGISTRY_IMAGE:builder-latest
|
||||
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
||||
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
|
||||
|
498
Cargo.lock
generated
498
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
20
Cargo.toml
20
Cargo.toml
@ -1,27 +1,27 @@
|
||||
[package]
|
||||
name = "hoc"
|
||||
version = "0.10.1"
|
||||
version = "0.11.3"
|
||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "1.0.5"
|
||||
actix-web = "1.0.7"
|
||||
badge = "0.2.0"
|
||||
bytes = "0.4.12"
|
||||
futures = "0.1.28"
|
||||
futures = "0.1.29"
|
||||
git2 = "0.9.1"
|
||||
lazy_static = "1.3.0"
|
||||
log = "0.4.7"
|
||||
lazy_static = "1.4.0"
|
||||
log = "0.4.8"
|
||||
log4rs = "0.8.3"
|
||||
number_prefix = "0.3.0"
|
||||
openssl-probe = "0.1.2"
|
||||
reqwest = "0.9.17"
|
||||
serde = "1.0.97"
|
||||
serde_derive = "1.0.97"
|
||||
reqwest = "0.9.20"
|
||||
serde = "1.0.101"
|
||||
serde_derive = "1.0.101"
|
||||
serde_json = "1.0.40"
|
||||
structopt = "0.2.18"
|
||||
structopt = "0.3.1"
|
||||
|
||||
[build-dependencies]
|
||||
ructe = "0.7.0"
|
||||
ructe = "0.7.2"
|
||||
vergen = "3.0.4"
|
||||
|
23
src/main.rs
23
src/main.rs
@ -137,8 +137,12 @@ fn hoc(repo: &str, repo_dir: &str, cache_dir: &str) -> Result<(u64, String, u64)
|
||||
Ok((cache.count, head, commits))
|
||||
}
|
||||
|
||||
fn remote_exists(url: &str) -> Result<bool> {
|
||||
Ok(CLIENT.head(url).send()?.status() == reqwest::StatusCode::OK)
|
||||
fn remote_exists(url: &str) -> impl Future<Item = bool, Error = Error> {
|
||||
CLIENT
|
||||
.head(url)
|
||||
.send()
|
||||
.map(|resp| resp.status() == reqwest::StatusCode::OK)
|
||||
.from_err()
|
||||
}
|
||||
|
||||
enum HocResult {
|
||||
@ -163,15 +167,15 @@ where
|
||||
T: Service,
|
||||
F: Fn(HocResult) -> Result<HttpResponse>,
|
||||
{
|
||||
futures::future::result(Ok(()))
|
||||
.and_then(move |_| {
|
||||
let repo = format!("{}/{}", data.0.to_lowercase(), data.1.to_lowercase());
|
||||
let service_path = format!("{}/{}", T::domain(), repo);
|
||||
let path = format!("{}/{}", state.repos, service_path);
|
||||
let repo = format!("{}/{}", data.0.to_lowercase(), data.1.to_lowercase());
|
||||
let service_path = format!("{}/{}", T::domain(), repo);
|
||||
let path = format!("{}/{}", state.repos, service_path);
|
||||
let url = format!("https://{}", service_path);
|
||||
remote_exists(&url)
|
||||
.and_then(move |remote_exists| {
|
||||
let file = Path::new(&path);
|
||||
let url = format!("https://{}", service_path);
|
||||
if !file.exists() {
|
||||
if !remote_exists(&url)? {
|
||||
if !remote_exists {
|
||||
warn!("Repository does not exist: {}", url);
|
||||
return Ok(HocResult::NotFound);
|
||||
}
|
||||
@ -351,6 +355,7 @@ fn start_server() -> Result<()> {
|
||||
App::new()
|
||||
.data(state.clone())
|
||||
.wrap(middleware::Logger::default())
|
||||
.wrap(middleware::NormalizePath)
|
||||
.service(index)
|
||||
.service(css)
|
||||
.service(favicon32)
|
||||
|
@ -15,7 +15,7 @@ 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 CLIENT: reqwest::r#async::Client = reqwest::r#async::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());
|
||||
|
Reference in New Issue
Block a user