Allow requesting badges for branches != master
This changed the cache structure to allow caching data for multiple branches. The service still assumes a default branch named `master` but using the `branch` get parameter, the default branch can be changed. The 404 page for the missing `master` branch was changed to explain the new parameter.
This commit is contained in:
parent
382cd73bae
commit
c9a54eda49
100
src/cache.rs
100
src/cache.rs
@ -1,6 +1,7 @@
|
|||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
|
collections::HashMap,
|
||||||
fs::{create_dir_all, File, OpenOptions},
|
fs::{create_dir_all, File, OpenOptions},
|
||||||
io::BufReader,
|
io::BufReader,
|
||||||
path::Path,
|
path::Path,
|
||||||
@ -9,49 +10,106 @@ 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 { count: u64, commits: u64 },
|
Current {
|
||||||
|
count: u64,
|
||||||
|
commits: u64,
|
||||||
|
cache: Cache<'a>,
|
||||||
|
},
|
||||||
/// Cached head is older than current head
|
/// Cached head is older than current head
|
||||||
Old(Cache<'a>),
|
Old {
|
||||||
|
head: String,
|
||||||
|
cache: Cache<'a>,
|
||||||
|
},
|
||||||
|
NoneForBranch(Cache<'a>),
|
||||||
/// No cache was found
|
/// No cache was found
|
||||||
No,
|
No,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CacheState<'a> {
|
impl<'a> CacheState<'a> {
|
||||||
pub(crate) fn read_from_file(path: impl AsRef<Path>, head: &str) -> Result<CacheState> {
|
pub(crate) fn read_from_file(
|
||||||
|
path: impl AsRef<Path>,
|
||||||
|
branch: &str,
|
||||||
|
head: &str,
|
||||||
|
) -> Result<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 {
|
Ok(cache
|
||||||
Ok(CacheState::Current {
|
.entries
|
||||||
count: cache.count,
|
.get(branch)
|
||||||
commits: cache.commits,
|
.map(|c| {
|
||||||
|
if c.head == head {
|
||||||
|
CacheState::Current {
|
||||||
|
count: c.count,
|
||||||
|
commits: c.commits,
|
||||||
|
// TODO: get rid of clone
|
||||||
|
cache: cache.clone(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CacheState::Old {
|
||||||
|
head: c.head.to_string(),
|
||||||
|
// TODO: get rid of clone
|
||||||
|
cache: cache.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
} else {
|
// TODO: get rid of clone
|
||||||
Ok(CacheState::Old(cache))
|
.unwrap_or_else(|| CacheState::NoneForBranch(cache.clone())))
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Ok(CacheState::No)
|
Ok(CacheState::No)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn calculate_new_cache(self, count: u64, commits: u64, head: Cow<'a, str>) -> Cache {
|
pub(crate) fn calculate_new_cache(
|
||||||
|
self,
|
||||||
|
count: u64,
|
||||||
|
commits: u64,
|
||||||
|
head: Cow<'a, str>,
|
||||||
|
branch: &'a str,
|
||||||
|
) -> Cache<'a> {
|
||||||
match self {
|
match self {
|
||||||
CacheState::Old(mut cache) => {
|
CacheState::Old { mut cache, .. } => {
|
||||||
cache.head = head;
|
if let Some(mut cache) = cache.entries.get_mut(branch) {
|
||||||
cache.count += count;
|
cache.head = head;
|
||||||
cache.commits += commits;
|
cache.count += count;
|
||||||
|
cache.commits += commits;
|
||||||
|
}
|
||||||
cache
|
cache
|
||||||
}
|
}
|
||||||
CacheState::No | CacheState::Current { .. } => Cache {
|
CacheState::Current { cache, .. } => cache,
|
||||||
head,
|
CacheState::NoneForBranch(mut cache) => {
|
||||||
count,
|
cache.entries.insert(
|
||||||
commits,
|
branch.into(),
|
||||||
},
|
CacheEntry {
|
||||||
|
head,
|
||||||
|
count,
|
||||||
|
commits,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
cache
|
||||||
|
}
|
||||||
|
CacheState::No => {
|
||||||
|
let mut entries = HashMap::with_capacity(1);
|
||||||
|
entries.insert(
|
||||||
|
branch.into(),
|
||||||
|
CacheEntry {
|
||||||
|
commits,
|
||||||
|
head,
|
||||||
|
count,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
Cache { entries }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
pub(crate) struct Cache<'a> {
|
pub(crate) struct Cache<'a> {
|
||||||
|
pub entries: HashMap<Cow<'a, str>, CacheEntry<'a>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
|
pub(crate) struct CacheEntry<'a> {
|
||||||
/// HEAD commit ref
|
/// HEAD commit ref
|
||||||
pub head: Cow<'a, str>,
|
pub head: Cow<'a, str>,
|
||||||
/// HoC value
|
/// HoC value
|
||||||
|
@ -50,7 +50,6 @@ pub(crate) struct Opt {
|
|||||||
|
|
||||||
pub(crate) async fn init() -> Result<()> {
|
pub(crate) async fn init() -> Result<()> {
|
||||||
std::env::set_var("RUST_LOG", "actix_web=info,hoc=info");
|
std::env::set_var("RUST_LOG", "actix_web=info,hoc=info");
|
||||||
// pretty_env_logger::init();
|
|
||||||
openssl_probe::init_ssl_cert_env_vars();
|
openssl_probe::init_ssl_cert_env_vars();
|
||||||
let stdout = ConsoleAppender::builder().build();
|
let stdout = ConsoleAppender::builder().build();
|
||||||
let file = FileAppender::builder()
|
let file = FileAppender::builder()
|
||||||
|
@ -18,7 +18,7 @@ pub(crate) enum Error {
|
|||||||
LogBuilder(log4rs::config::Errors),
|
LogBuilder(log4rs::config::Errors),
|
||||||
Parse(std::num::ParseIntError),
|
Parse(std::num::ParseIntError),
|
||||||
Serial(serde_json::Error),
|
Serial(serde_json::Error),
|
||||||
GitNoMaster,
|
BranchNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
@ -33,7 +33,7 @@ impl fmt::Display for Error {
|
|||||||
Error::LogBuilder(e) => write!(fmt, "LogBuilder({})", e),
|
Error::LogBuilder(e) => write!(fmt, "LogBuilder({})", e),
|
||||||
Error::Parse(e) => write!(fmt, "Parse({})", 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"),
|
Error::BranchNotFound => write!(fmt, "Repo doesn't have master branch"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ impl ResponseError for Error {
|
|||||||
fn error_response(&self) -> HttpResponse {
|
fn error_response(&self) -> HttpResponse {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
match self {
|
match self {
|
||||||
Error::GitNoMaster => {
|
Error::BranchNotFound => {
|
||||||
templates::p404_no_master(
|
templates::p404_no_master(
|
||||||
&mut buf,
|
&mut buf,
|
||||||
VERSION_INFO,
|
VERSION_INFO,
|
||||||
|
59
src/main.rs
59
src/main.rs
@ -32,7 +32,7 @@ use actix_web::{
|
|||||||
middleware, web, App, HttpResponse, HttpServer, Responder,
|
middleware, web, App, HttpResponse, HttpServer, Responder,
|
||||||
};
|
};
|
||||||
use badge::{Badge, BadgeOptions};
|
use badge::{Badge, BadgeOptions};
|
||||||
use git2::Repository;
|
use git2::{BranchType, Repository};
|
||||||
use number_prefix::NumberPrefix;
|
use number_prefix::NumberPrefix;
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
@ -63,10 +63,16 @@ pub(crate) struct State {
|
|||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct JsonResponse<'a> {
|
struct JsonResponse<'a> {
|
||||||
head: &'a str,
|
head: &'a str,
|
||||||
|
branch: &'a str,
|
||||||
count: u64,
|
count: u64,
|
||||||
commits: u64,
|
commits: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
struct BranchQuery {
|
||||||
|
branch: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
fn pull(path: impl AsRef<Path>) -> Result<()> {
|
fn pull(path: impl AsRef<Path>) -> Result<()> {
|
||||||
let repo = Repository::open_bare(path)?;
|
let repo = Repository::open_bare(path)?;
|
||||||
let mut origin = repo.find_remote("origin")?;
|
let mut origin = repo.find_remote("origin")?;
|
||||||
@ -74,17 +80,17 @@ fn pull(path: impl AsRef<Path>) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hoc(repo: &str, repo_dir: &str, cache_dir: &str) -> Result<(u64, String, u64)> {
|
fn hoc(repo: &str, repo_dir: &str, cache_dir: &str, branch: &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 repo = Repository::open_bare(&repo_dir)?;
|
let repo = Repository::open_bare(&repo_dir)?;
|
||||||
// TODO: do better...
|
// TODO: do better...
|
||||||
let head = match repo.head() {
|
let head = repo
|
||||||
Ok(v) => v,
|
.find_branch(branch, BranchType::Local)
|
||||||
Err(_) => return Err(Error::GitNoMaster),
|
.map_err(|_| Error::BranchNotFound)?
|
||||||
};
|
.into_reference();
|
||||||
let head = format!("{}", head.target().ok_or(Error::Internal)?);
|
let head = format!("{}", head.target().ok_or(Error::BranchNotFound)?);
|
||||||
let mut arg_commit_count = vec!["rev-list".to_string(), "--count".to_string()];
|
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(),
|
||||||
@ -98,26 +104,27 @@ fn hoc(repo: &str, repo_dir: &str, cache_dir: &str) -> Result<(u64, String, u64)
|
|||||||
"-M".to_string(),
|
"-M".to_string(),
|
||||||
"--diff-filter=ACDM".to_string(),
|
"--diff-filter=ACDM".to_string(),
|
||||||
];
|
];
|
||||||
let cache = CacheState::read_from_file(&cache_dir, &head)?;
|
let cache = CacheState::read_from_file(&cache_dir, branch, &head)?;
|
||||||
match &cache {
|
match &cache {
|
||||||
CacheState::Current { count, commits } => {
|
CacheState::Current { count, commits, .. } => {
|
||||||
info!("Using cache for {}", repo_dir);
|
info!("Using cache for {}", repo_dir);
|
||||||
return Ok((*count, head, *commits));
|
return Ok((*count, head, *commits));
|
||||||
}
|
}
|
||||||
CacheState::Old(cache) => {
|
CacheState::Old { head, .. } => {
|
||||||
info!("Updating cache for {}", repo_dir);
|
info!("Updating cache for {}", repo_dir);
|
||||||
arg.push(format!("{}..HEAD", cache.head));
|
arg.push(format!("{}..{}", head, branch));
|
||||||
arg_commit_count.push(format!("{}..HEAD", cache.head));
|
arg_commit_count.push(format!("{}..{}", head, branch));
|
||||||
}
|
}
|
||||||
CacheState::No => {
|
CacheState::No | CacheState::NoneForBranch(..) => {
|
||||||
info!("Creating cache for {}", repo_dir);
|
info!("Creating cache for {}", repo_dir);
|
||||||
arg_commit_count.push("HEAD".to_string());
|
arg.push(branch.to_string());
|
||||||
|
arg_commit_count.push(branch.to_string());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
arg.push("--".to_string());
|
arg.push("--".to_string());
|
||||||
arg.push(".".to_string());
|
arg.push(".".to_string());
|
||||||
let output = Command::new("git")
|
let output = Command::new("git")
|
||||||
.args(&arg)
|
.args(&dbg!(arg))
|
||||||
.current_dir(&repo_dir)
|
.current_dir(&repo_dir)
|
||||||
.output()?
|
.output()?
|
||||||
.stdout;
|
.stdout;
|
||||||
@ -140,10 +147,10 @@ fn hoc(repo: &str, repo_dir: &str, cache_dir: &str) -> Result<(u64, String, u64)
|
|||||||
})
|
})
|
||||||
.sum();
|
.sum();
|
||||||
|
|
||||||
let cache = cache.calculate_new_cache(count, commits, (&head).into());
|
let cache = cache.calculate_new_cache(count, commits, (&head).into(), branch);
|
||||||
cache.write_to_file(cache_dir)?;
|
cache.write_to_file(cache_dir)?;
|
||||||
|
|
||||||
Ok((cache.count, head, commits))
|
Ok((count, head, commits))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn remote_exists(url: &str) -> Result<bool> {
|
async fn remote_exists(url: &str) -> Result<bool> {
|
||||||
@ -206,6 +213,7 @@ where
|
|||||||
async 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)>,
|
||||||
|
branch: &str,
|
||||||
mapper: F,
|
mapper: F,
|
||||||
) -> Result<HttpResponse>
|
) -> Result<HttpResponse>
|
||||||
where
|
where
|
||||||
@ -217,7 +225,6 @@ where
|
|||||||
let service_url = format!("{}/{}", T::domain(), repo);
|
let service_url = format!("{}/{}", T::domain(), repo);
|
||||||
let path = format!("{}/{}", state.repos, service_url);
|
let path = format!("{}/{}", state.repos, service_url);
|
||||||
let url = format!("https://{}", service_url);
|
let url = format!("https://{}", service_url);
|
||||||
error!("{}", url);
|
|
||||||
let remote_exists = remote_exists(&url).await?;
|
let remote_exists = remote_exists(&url).await?;
|
||||||
let file = Path::new(&path);
|
let file = Path::new(&path);
|
||||||
if !file.exists() {
|
if !file.exists() {
|
||||||
@ -233,7 +240,7 @@ where
|
|||||||
REPO_COUNT.fetch_add(1, Ordering::Relaxed);
|
REPO_COUNT.fetch_add(1, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
pull(&path)?;
|
pull(&path)?;
|
||||||
let (hoc, head, commits) = hoc(&service_url, &state.repos, &state.cache)?;
|
let (hoc, head, commits) = hoc(&service_url, &state.repos, &state.cache, branch)?;
|
||||||
let hoc_pretty = match NumberPrefix::decimal(hoc as f64) {
|
let hoc_pretty = match NumberPrefix::decimal(hoc as f64) {
|
||||||
NumberPrefix::Standalone(hoc) => hoc.to_string(),
|
NumberPrefix::Standalone(hoc) => hoc.to_string(),
|
||||||
NumberPrefix::Prefixed(prefix, hoc) => format!("{:.1}{}", hoc, prefix),
|
NumberPrefix::Prefixed(prefix, hoc) => format!("{:.1}{}", hoc, prefix),
|
||||||
@ -253,23 +260,27 @@ where
|
|||||||
pub(crate) async fn json_hoc<T: Service>(
|
pub(crate) async fn json_hoc<T: Service>(
|
||||||
state: web::Data<Arc<State>>,
|
state: web::Data<Arc<State>>,
|
||||||
data: web::Path<(String, String)>,
|
data: web::Path<(String, String)>,
|
||||||
|
branch: web::Query<BranchQuery>,
|
||||||
) -> Result<HttpResponse> {
|
) -> Result<HttpResponse> {
|
||||||
|
let branch = branch.branch.as_deref().unwrap_or("master");
|
||||||
let mapper = |r| match r {
|
let mapper = |r| match r {
|
||||||
HocResult::NotFound => p404(),
|
HocResult::NotFound => p404(),
|
||||||
HocResult::Hoc {
|
HocResult::Hoc {
|
||||||
hoc, head, commits, ..
|
hoc, head, commits, ..
|
||||||
} => Ok(HttpResponse::Ok().json(JsonResponse {
|
} => Ok(HttpResponse::Ok().json(JsonResponse {
|
||||||
|
branch,
|
||||||
head: &head,
|
head: &head,
|
||||||
count: hoc,
|
count: hoc,
|
||||||
commits,
|
commits,
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
handle_hoc_request::<T, _>(state, data, mapper).await
|
handle_hoc_request::<T, _>(state, data, branch, mapper).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn calculate_hoc<T: Service>(
|
pub(crate) async 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)>,
|
||||||
|
branch: web::Query<BranchQuery>,
|
||||||
) -> Result<HttpResponse> {
|
) -> Result<HttpResponse> {
|
||||||
let mapper = move |r| match r {
|
let mapper = move |r| match r {
|
||||||
HocResult::NotFound => p404(),
|
HocResult::NotFound => p404(),
|
||||||
@ -296,13 +307,16 @@ pub(crate) async fn calculate_hoc<T: Service>(
|
|||||||
.body(body))
|
.body(body))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
handle_hoc_request::<T, _>(state, data, mapper).await
|
let branch = branch.branch.as_deref().unwrap_or("master");
|
||||||
|
handle_hoc_request::<T, _>(state, data, branch, mapper).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn overview<T: Service>(
|
async fn overview<T: Service>(
|
||||||
state: web::Data<Arc<State>>,
|
state: web::Data<Arc<State>>,
|
||||||
data: web::Path<(String, String)>,
|
data: web::Path<(String, String)>,
|
||||||
|
branch: web::Query<BranchQuery>,
|
||||||
) -> Result<HttpResponse> {
|
) -> Result<HttpResponse> {
|
||||||
|
let branch = branch.branch.as_deref().unwrap_or("master");
|
||||||
let mapper = |r| match r {
|
let mapper = |r| match r {
|
||||||
HocResult::NotFound => p404(),
|
HocResult::NotFound => p404(),
|
||||||
HocResult::Hoc {
|
HocResult::Hoc {
|
||||||
@ -324,6 +338,7 @@ async fn overview<T: Service>(
|
|||||||
hoc_pretty: &hoc_pretty,
|
hoc_pretty: &hoc_pretty,
|
||||||
path: &service_path,
|
path: &service_path,
|
||||||
url: &url,
|
url: &url,
|
||||||
|
branch,
|
||||||
};
|
};
|
||||||
templates::overview(
|
templates::overview(
|
||||||
&mut buf,
|
&mut buf,
|
||||||
@ -335,7 +350,7 @@ async fn overview<T: Service>(
|
|||||||
Ok(HttpResponse::Ok().content_type("text/html").body(buf))
|
Ok(HttpResponse::Ok().content_type("text/html").body(buf))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
handle_hoc_request::<T, _>(state, data, mapper).await
|
handle_hoc_request::<T, _>(state, data, branch, mapper).await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
|
@ -7,4 +7,5 @@ pub struct RepoInfo<'a> {
|
|||||||
pub hoc_pretty: &'a str,
|
pub hoc_pretty: &'a str,
|
||||||
pub path: &'a str,
|
pub path: &'a str,
|
||||||
pub url: &'a str,
|
pub url: &'a str,
|
||||||
|
pub branch: &'a str,
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,12 @@ would render this badge:
|
|||||||
alt="example badge" /></a>
|
alt="example badge" /></a>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
By default, this service assumes the existence of a branch named <code>master</code>. If no branch with that name exists
|
||||||
|
in your repository or you want a badge for another branch of your repository, just append
|
||||||
|
<code>?branch=<branch-name></code> to the URL.
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
You can also request the HoC as JSON by appending <code>/json</code> to the request path. This will return a JSON object
|
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
|
with three fields: <code>count</code> (the HoC value), <code>commits</code> (the number of commits) and
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
<p>
|
<p>
|
||||||
The project <a href="@repo_info.url">@repo_info.url</a> has
|
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
|
<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
|
<a href="@repo_info.commit_url">@repo_info.head</a> on the
|
||||||
|
<code>@repo_info.branch</code> branch. The repository contains
|
||||||
<strong>@repo_info.commits</strong> commits.
|
<strong>@repo_info.commits</strong> commits.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ To include the badge in your readme, use the following markdown:
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
[![Hits-of-Code](https://@repo_info.domain/@repo_info.path)](https://@repo_info.domain/view/@repo_info.path)
|
[![Hits-of-Code](https://@repo_info.domain/@repo_info.path?branch=@repo_info.branch)](https://@repo_info.domain/view/@repo_info.path?branch=@repo_info.branch)
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
@(version_info: VersionInfo, repo_count: usize)
|
@(version_info: VersionInfo, repo_count: usize)
|
||||||
|
|
||||||
@:base("Master Branch not Found - Hits-of-Code Badges", "404 - Master Branch not Found", {
|
@:base("Branch not Found - Hits-of-Code Badges", "404 - Branch not Found", {
|
||||||
<p>
|
<p>
|
||||||
<big>Sorry</big>. I couldn't find the master branch of your repositroy.
|
<big>Sorry</big>. I couldn't find the requested branch of your repositroy. Currently this service assumes the
|
||||||
Currently this service depends on the existence of a master branch. Please go
|
extistence of a branch named <code>master</code>. If you'd like to request a badge for another branch, you can do so by
|
||||||
<a href="/">back to the homepage</a>.
|
attaching <code>?branch=<branch-name></code> to the request.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
Loading…
Reference in New Issue
Block a user