Compare commits
39 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
@ -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
|
||||||
|
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]
|
[package]
|
||||||
name = "hoc"
|
name = "hoc"
|
||||||
version = "0.10.1"
|
version = "0.11.3"
|
||||||
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.5"
|
actix-web = "1.0.7"
|
||||||
badge = "0.2.0"
|
badge = "0.2.0"
|
||||||
bytes = "0.4.12"
|
bytes = "0.4.12"
|
||||||
futures = "0.1.28"
|
futures = "0.1.29"
|
||||||
git2 = "0.9.1"
|
git2 = "0.9.1"
|
||||||
lazy_static = "1.3.0"
|
lazy_static = "1.4.0"
|
||||||
log = "0.4.7"
|
log = "0.4.8"
|
||||||
log4rs = "0.8.3"
|
log4rs = "0.8.3"
|
||||||
number_prefix = "0.3.0"
|
number_prefix = "0.3.0"
|
||||||
openssl-probe = "0.1.2"
|
openssl-probe = "0.1.2"
|
||||||
reqwest = "0.9.17"
|
reqwest = "0.9.20"
|
||||||
serde = "1.0.97"
|
serde = "1.0.100"
|
||||||
serde_derive = "1.0.97"
|
serde_derive = "1.0.100"
|
||||||
serde_json = "1.0.40"
|
serde_json = "1.0.40"
|
||||||
structopt = "0.2.18"
|
structopt = "0.3.1"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
ructe = "0.7.0"
|
ructe = "0.7.2"
|
||||||
vergen = "3.0.4"
|
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))
|
Ok((cache.count, head, commits))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remote_exists(url: &str) -> Result<bool> {
|
fn remote_exists(url: &str) -> impl Future<Item = bool, Error = Error> {
|
||||||
Ok(CLIENT.head(url).send()?.status() == reqwest::StatusCode::OK)
|
CLIENT
|
||||||
|
.head(url)
|
||||||
|
.send()
|
||||||
|
.map(|resp| resp.status() == reqwest::StatusCode::OK)
|
||||||
|
.from_err()
|
||||||
}
|
}
|
||||||
|
|
||||||
enum HocResult {
|
enum HocResult {
|
||||||
@ -163,15 +167,15 @@ where
|
|||||||
T: Service,
|
T: Service,
|
||||||
F: Fn(HocResult) -> Result<HttpResponse>,
|
F: Fn(HocResult) -> Result<HttpResponse>,
|
||||||
{
|
{
|
||||||
futures::future::result(Ok(()))
|
let repo = format!("{}/{}", data.0.to_lowercase(), data.1.to_lowercase());
|
||||||
.and_then(move |_| {
|
let service_path = format!("{}/{}", T::domain(), repo);
|
||||||
let repo = format!("{}/{}", data.0.to_lowercase(), data.1.to_lowercase());
|
let path = format!("{}/{}", state.repos, service_path);
|
||||||
let service_path = format!("{}/{}", T::domain(), repo);
|
let url = format!("https://{}", service_path);
|
||||||
let path = format!("{}/{}", state.repos, service_path);
|
remote_exists(&url)
|
||||||
|
.and_then(move |remote_exists| {
|
||||||
let file = Path::new(&path);
|
let file = Path::new(&path);
|
||||||
let url = format!("https://{}", service_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 Ok(HocResult::NotFound);
|
||||||
}
|
}
|
||||||
@ -351,6 +355,7 @@ fn start_server() -> 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(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");
|
pub(crate) const FAVICON: &[u8] = include_bytes!("../static/favicon32.png");
|
||||||
|
|
||||||
lazy_static! {
|
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 OPT: Opt = Opt::from_args();
|
||||||
pub(crate) static ref REPO_COUNT: AtomicUsize =
|
pub(crate) static ref REPO_COUNT: AtomicUsize =
|
||||||
AtomicUsize::new(count_repositories(&OPT.outdir).unwrap());
|
AtomicUsize::new(count_repositories(&OPT.outdir).unwrap());
|
||||||
|
Reference in New Issue
Block a user