mirror of
https://github.com/rust-unofficial/awesome-rust.git
synced 2025-02-04 06:08:43 +02:00
Catch github actions badges with no branch
This commit is contained in:
parent
d17daf5187
commit
5bceef3656
15
src/main.rs
15
src/main.rs
@ -32,6 +32,9 @@ enum CheckerError {
|
|||||||
|
|
||||||
#[fail(display = "travis build is unknown")]
|
#[fail(display = "travis build is unknown")]
|
||||||
TravisBuildUnknown,
|
TravisBuildUnknown,
|
||||||
|
|
||||||
|
#[fail(display = "github actions image with no branch")]
|
||||||
|
GithubActionNoBranch,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MaxHandles {
|
struct MaxHandles {
|
||||||
@ -141,6 +144,7 @@ fn get_url(url: String) -> BoxFuture<'static, (String, Result<String, CheckerErr
|
|||||||
}
|
}
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref TRAVIS_IMG_REGEX: Regex = Regex::new(r"https://api.travis-ci.(?:com|org)/[^/]+/.+\.svg").unwrap();
|
static ref TRAVIS_IMG_REGEX: Regex = Regex::new(r"https://api.travis-ci.(?:com|org)/[^/]+/.+\.svg").unwrap();
|
||||||
|
static ref GITHUB_ACTIONS_REGEX: Regex = Regex::new(r"https://github.com/[^/]+/[^/]+/workflows/[^/]+/badge.svg(\?.+)?").unwrap();
|
||||||
}
|
}
|
||||||
if TRAVIS_IMG_REGEX.is_match(&url) {
|
if TRAVIS_IMG_REGEX.is_match(&url) {
|
||||||
let content_dispostion = ok.headers().get(header::CONTENT_DISPOSITION).and_then(|h| h.to_str().ok()).unwrap_or("");
|
let content_dispostion = ok.headers().get(header::CONTENT_DISPOSITION).and_then(|h| h.to_str().ok()).unwrap_or("");
|
||||||
@ -150,6 +154,14 @@ fn get_url(url: String) -> BoxFuture<'static, (String, Result<String, CheckerErr
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let Some(matches) = GITHUB_ACTIONS_REGEX.captures(&url) {
|
||||||
|
debug!("Github actions match {:?}", matches);
|
||||||
|
let query = matches.get(1).map(|x| x.as_str()).unwrap_or("");
|
||||||
|
if !query.starts_with("?") || query.find("branch=").is_none() {
|
||||||
|
res = Err(CheckerError::GithubActionNoBranch);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
debug!("Finished {}", url);
|
debug!("Finished {}", url);
|
||||||
res = Ok(format!("{:?}", ok));
|
res = Ok(format!("{:?}", ok));
|
||||||
break;
|
break;
|
||||||
@ -254,6 +266,9 @@ async fn main() -> Result<(), Error> {
|
|||||||
CheckerError::TravisBuildUnknown => {
|
CheckerError::TravisBuildUnknown => {
|
||||||
format!("[Unknown travis build] {}", url)
|
format!("[Unknown travis build] {}", url)
|
||||||
}
|
}
|
||||||
|
CheckerError::GithubActionNoBranch => {
|
||||||
|
format!("[Github action image with no branch specified] {}", url)
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
format!("{:?}", err)
|
format!("{:?}", err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user