mirror of
https://github.com/rust-unofficial/awesome-rust.git
synced 2024-12-07 11:13:18 +02:00
Merge pull request #831 from palfrey/better-unknown-travis-detection
Better unknown travis detection
This commit is contained in:
commit
3c7648ecc7
@ -1428,7 +1428,7 @@ See also [Are we web yet?](http://www.arewewebyet.org) and [Rust web framework c
|
||||
* Reverse Proxy
|
||||
* [sozu-proxy/sozu](https://github.com/sozu-proxy/sozu) [[sozu](https://crates.io/crates/sozu)] — A HTTP reverse proxy. [![Build Status](https://api.travis-ci.org/sozu-proxy/sozu.svg?branch=master)](https://travis-ci.org/sozu-proxy/sozu)
|
||||
* Static Site Generators
|
||||
* [getzola/zola](https://github.com/getzola/zola) [[zola](https://www.getzola.org/)] — An opinionated static site generator with everything built-in. [![Build Status](https://api.travis-ci.com/getzola/zola.svg?branch=master)](https://travis-ci.org/getzola/zola)
|
||||
* [getzola/zola](https://github.com/getzola/zola) [[zola](https://www.getzola.org/)] — An opinionated static site generator with everything built-in. [![Build Status](https://dev.azure.com/getzola/zola/_apis/build/status/getzola.zola?branchName=master)](https://dev.azure.com/getzola/zola/_build/latest?definitionId=1&branchName=master)
|
||||
* [cobalt-org/cobalt.rs](https://github.com/cobalt-org/cobalt.rs) — Static site generator written in Rust [<img src="https://api.travis-ci.org/cobalt-org/cobalt.rs.svg?branch=master">](https://travis-ci.org/cobalt-org/cobalt.rs)
|
||||
* [FuGangqiang/mdblog.rs](https://github.com/FuGangqiang/mdblog.rs) — Static site generator from markdown files.
|
||||
* [leven-the-blog/leven](https://github.com/leven-the-blog/leven) [[leven](https://crates.io/crates/leven)] — A simple, parallelized blog generator. [<img src="https://api.travis-ci.org/quadrupleslap/leven.svg?branch=master">](https://travis-ci.org/quadrupleslap/leven)
|
||||
|
13
src/main.rs
13
src/main.rs
@ -87,7 +87,7 @@ lazy_static! {
|
||||
static ref HANDLES: MaxHandles = MaxHandles::new(20);
|
||||
}
|
||||
|
||||
fn get_url(url: String) -> BoxFuture<'static, (String, Result<String, CheckerError>)> {
|
||||
fn get_url(url: String) -> BoxFuture<'static, (String, Result<(), CheckerError>)> {
|
||||
async move {
|
||||
let _handle = HANDLES.get().await;
|
||||
let mut res = Err(CheckerError::NotTried);
|
||||
@ -104,7 +104,7 @@ fn get_url(url: String) -> BoxFuture<'static, (String, Result<String, CheckerErr
|
||||
res = Err(CheckerError::ReqwestError{error: err});
|
||||
continue;
|
||||
}
|
||||
Ok(ref ok) => {
|
||||
Ok(ok) => {
|
||||
let status = ok.status();
|
||||
if status != StatusCode::OK {
|
||||
lazy_static! {
|
||||
@ -150,9 +150,10 @@ fn get_url(url: String) -> BoxFuture<'static, (String, Result<String, CheckerErr
|
||||
static ref GITHUB_ACTIONS_REGEX: Regex = Regex::new(r"https://github.com/[^/]+/[^/]+/workflows/[^/]+/badge.svg(\?.+)?").unwrap();
|
||||
}
|
||||
if let Some(matches) = TRAVIS_IMG_REGEX.captures(&url) {
|
||||
let content_dispostion = ok.headers().get(header::CONTENT_DISPOSITION).and_then(|h| h.to_str().ok()).unwrap_or("");
|
||||
debug!("Content dispostion for {} is '{}'", content_dispostion, url);
|
||||
if content_dispostion == "inline; filename=\"unknown.svg\"" {
|
||||
// Previously we checked the Content-Disposition headers, but sometimes that is incorrect
|
||||
// We're now looking for the explicit text "unknown" in the middle of the SVG
|
||||
let content = ok.text().await.unwrap();
|
||||
if content.contains("unknown") {
|
||||
res = Err(CheckerError::TravisBuildUnknown);
|
||||
break;
|
||||
}
|
||||
@ -171,7 +172,7 @@ fn get_url(url: String) -> BoxFuture<'static, (String, Result<String, CheckerErr
|
||||
}
|
||||
}
|
||||
debug!("Finished {}", url);
|
||||
res = Ok(format!("{:?}", ok));
|
||||
res = Ok(());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user