Compare commits
65 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
@ -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
|
||||||
|
588
Cargo.lock
generated
588
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
22
Cargo.toml
22
Cargo.toml
@ -1,27 +1,27 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "hoc"
|
name = "hoc"
|
||||||
version = "0.9.3"
|
version = "0.11.2"
|
||||||
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.2"
|
actix-web = "1.0.5"
|
||||||
badge = "0.2.0"
|
badge = "0.2.0"
|
||||||
bytes = "0.4.12"
|
bytes = "0.4.12"
|
||||||
futures = "0.1.27"
|
futures = "0.1.28"
|
||||||
git2 = "0.9.1"
|
git2 = "0.9.1"
|
||||||
lazy_static = "1.3.0"
|
lazy_static = "1.4.0"
|
||||||
log = "0.4.6"
|
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.93"
|
serde = "1.0.99"
|
||||||
serde_derive = "1.0.93"
|
serde_derive = "1.0.99"
|
||||||
serde_json = "1.0.39"
|
serde_json = "1.0.40"
|
||||||
structopt = "0.2.16"
|
structopt = "0.2.18"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
ructe = "0.6.4"
|
ructe = "0.7.0"
|
||||||
vergen = "3.0.4"
|
vergen = "3.0.4"
|
||||||
|
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
|
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}"
|
20
src/cache.rs
20
src/cache.rs
@ -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
|
||||||
@ -21,7 +21,10 @@ impl<'a> CacheState<'a> {
|
|||||||
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,22 +33,31 @@ 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> {
|
||||||
|
@ -16,6 +16,7 @@ pub(crate) enum Error {
|
|||||||
Io(std::io::Error),
|
Io(std::io::Error),
|
||||||
Log(log::SetLoggerError),
|
Log(log::SetLoggerError),
|
||||||
LogBuilder(log4rs::config::Errors),
|
LogBuilder(log4rs::config::Errors),
|
||||||
|
Parse(std::num::ParseIntError),
|
||||||
Serial(serde_json::Error),
|
Serial(serde_json::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ impl fmt::Display for Error {
|
|||||||
Error::Io(e) => write!(fmt, "Io({})", e),
|
Error::Io(e) => write!(fmt, "Io({})", e),
|
||||||
Error::Log(e) => write!(fmt, "Log({})", e),
|
Error::Log(e) => write!(fmt, "Log({})", e),
|
||||||
Error::LogBuilder(e) => write!(fmt, "LogBuilder({})", 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),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,3 +93,9 @@ impl From<log4rs::config::Errors> for Error {
|
|||||||
Error::LogBuilder(err)
|
Error::LogBuilder(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<std::num::ParseIntError> for Error {
|
||||||
|
fn from(err: std::num::ParseIntError) -> Self {
|
||||||
|
Error::Parse(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
74
src/main.rs
74
src/main.rs
@ -60,6 +60,7 @@ struct State {
|
|||||||
struct JsonResponse<'a> {
|
struct JsonResponse<'a> {
|
||||||
head: &'a str,
|
head: &'a str,
|
||||||
count: u64,
|
count: u64,
|
||||||
|
commits: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pull(path: impl AsRef<Path>) -> Result<()> {
|
fn pull(path: impl AsRef<Path>) -> Result<()> {
|
||||||
@ -69,17 +70,13 @@ 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)?;
|
||||||
"{}",
|
let head = format!("{}", repo.head()?.target().ok_or(Error::Internal)?);
|
||||||
Repository::open_bare(&repo_dir)?
|
let mut arg_commit_count = vec!["rev-list".to_string(), "--count".to_string()];
|
||||||
.head()?
|
|
||||||
.target()
|
|
||||||
.ok_or(Error::Internal)?
|
|
||||||
);
|
|
||||||
let mut arg = vec![
|
let mut arg = vec![
|
||||||
"log".to_string(),
|
"log".to_string(),
|
||||||
"--pretty=tformat:".to_string(),
|
"--pretty=tformat:".to_string(),
|
||||||
@ -94,16 +91,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());
|
||||||
@ -114,6 +113,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| {
|
||||||
@ -125,19 +131,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> {
|
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 {
|
||||||
Hoc {
|
Hoc {
|
||||||
hoc: u64,
|
hoc: u64,
|
||||||
|
commits: u64,
|
||||||
hoc_pretty: String,
|
hoc_pretty: String,
|
||||||
head: String,
|
head: String,
|
||||||
url: String,
|
url: String,
|
||||||
@ -156,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);
|
||||||
}
|
}
|
||||||
@ -176,15 +187,16 @@ where
|
|||||||
REPO_COUNT.fetch_add(1, Ordering::Relaxed);
|
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 {
|
Ok(HocResult::Hoc {
|
||||||
hoc,
|
hoc,
|
||||||
|
commits,
|
||||||
hoc_pretty,
|
hoc_pretty,
|
||||||
head,
|
head: head.to_string(),
|
||||||
url,
|
url,
|
||||||
repo,
|
repo,
|
||||||
service_path,
|
service_path,
|
||||||
@ -199,9 +211,12 @@ fn json_hoc<T: Service>(
|
|||||||
) -> impl Future<Item = HttpResponse, Error = Error> {
|
) -> impl Future<Item = HttpResponse, Error = Error> {
|
||||||
let mapper = |r| match r {
|
let mapper = |r| match r {
|
||||||
HocResult::NotFound => p404(),
|
HocResult::NotFound => p404(),
|
||||||
HocResult::Hoc { hoc, head, .. } => Ok(HttpResponse::Ok().json(JsonResponse {
|
HocResult::Hoc {
|
||||||
|
hoc, head, commits, ..
|
||||||
|
} => Ok(HttpResponse::Ok().json(JsonResponse {
|
||||||
head: &head,
|
head: &head,
|
||||||
count: hoc,
|
count: hoc,
|
||||||
|
commits,
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
handle_hoc_request::<T, _>(state, data, mapper)
|
handle_hoc_request::<T, _>(state, data, mapper)
|
||||||
@ -248,6 +263,7 @@ fn overview<T: Service>(
|
|||||||
HocResult::NotFound => p404(),
|
HocResult::NotFound => p404(),
|
||||||
HocResult::Hoc {
|
HocResult::Hoc {
|
||||||
hoc,
|
hoc,
|
||||||
|
commits,
|
||||||
hoc_pretty,
|
hoc_pretty,
|
||||||
url,
|
url,
|
||||||
head,
|
head,
|
||||||
@ -266,6 +282,7 @@ fn overview<T: Service>(
|
|||||||
&hoc_pretty,
|
&hoc_pretty,
|
||||||
&head,
|
&head,
|
||||||
&T::commit_url(&repo, &head),
|
&T::commit_url(&repo, &head),
|
||||||
|
commits,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let (tx, rx_body) = mpsc::unbounded();
|
let (tx, rx_body) = mpsc::unbounded();
|
||||||
@ -328,8 +345,7 @@ fn favicon32() -> HttpResponse {
|
|||||||
HttpResponse::Ok().content_type("image/png").body(FAVICON)
|
HttpResponse::Ok().content_type("image/png").body(FAVICON)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn start_server() -> Result<()> {
|
||||||
config::init()?;
|
|
||||||
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(),
|
||||||
@ -339,6 +355,7 @@ fn main() -> 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)
|
||||||
@ -358,3 +375,8 @@ fn main() -> Result<()> {
|
|||||||
.bind(interface)?
|
.bind(interface)?
|
||||||
.run()?)
|
.run()?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn main() -> Result<()> {
|
||||||
|
config::init()?;
|
||||||
|
start_server()
|
||||||
|
}
|
||||||
|
@ -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());
|
||||||
|
@ -46,17 +46,18 @@ alt="example badge" /></a>
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
You can also request the HoC as JSON by appending <code>/json</code> to the request path. This will return a JSON
|
You can also request the HoC as JSON by appending <code>/json</code> to the request path. This will return a JSON object
|
||||||
object with two fields: <code>count</code> and <code>head</code> with count being the HoC value and head being the
|
with three fields: <code>count</code> (the HoC value), <code>commits</code> (the number of commits) and
|
||||||
commit ref of <code>HEAD</code>. Requesting
|
<code>head</code> (the commit ref of HEAD). Requesting <a
|
||||||
<a href="https://@domain/github/vbrandl/hoc/json">https://@domain/github/vbrandl/hoc/json</a> might return something
|
href="https://@domain/github/vbrandl/hoc/json">https://@domain/github/vbrandl/hoc/json</a> might return something along
|
||||||
along the lines of
|
the lines of
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
{
|
{
|
||||||
"head" : "05736ee3ba256ec9a7227c436aef2bf43db109ab",
|
"head": "1f01c3b964b018fb0c0c2c5b572bf4ace2968546",
|
||||||
"count": 7582
|
"count": 8324,
|
||||||
|
"commits": 223
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
@use super::base;
|
@use super::base;
|
||||||
@use crate::statics::VersionInfo;
|
@use crate::statics::VersionInfo;
|
||||||
|
|
||||||
@(version_info: VersionInfo, repo_count: usize, domain: &str, path: &str, url: &str, hoc: u64, hoc_pretty: &str, head: &str, commit_url: &str)
|
@(version_info: VersionInfo, repo_count: usize, domain: &str, path: &str, url: &str, hoc: u64, hoc_pretty: &str, head: &str, commit_url: &str, commits: u64)
|
||||||
|
|
||||||
@: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="@url">@url</a> has <strong>@hoc_pretty</strong> (exactly @hoc) hits of code at
|
||||||
|
<a href="@commit_url">@head</a>. The repository contains <strong>@commits</strong> commits.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
Reference in New Issue
Block a user