httpd: Fix status code in commit history endpoint
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
parent
de8e92d48c
commit
fdd6bca311
|
|
@ -138,12 +138,12 @@ async fn history_handler(
|
||||||
per_page,
|
per_page,
|
||||||
} = qs;
|
} = qs;
|
||||||
|
|
||||||
let (sha, fallback_to_head) = match parent {
|
let sha = match parent {
|
||||||
Some(commit) => (commit, false),
|
Some(commit) => commit,
|
||||||
None => {
|
None => {
|
||||||
let info = ctx.project_info(project)?;
|
let info = ctx.project_info(project)?;
|
||||||
|
|
||||||
(info.head.to_string(), true)
|
info.head.to_string()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -201,10 +201,6 @@ async fn history_handler(
|
||||||
"stats": repo.stats()?,
|
"stats": repo.stats()?,
|
||||||
});
|
});
|
||||||
|
|
||||||
if fallback_to_head {
|
|
||||||
return Ok::<_, Error>((StatusCode::FOUND, Json(response)));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok::<_, Error>((StatusCode::OK, Json(response)))
|
Ok::<_, Error>((StatusCode::OK, Json(response)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -689,7 +685,7 @@ mod routes {
|
||||||
let app = super::router(test::seed(tmp.path()));
|
let app = super::router(test::seed(tmp.path()));
|
||||||
let response = get(&app, format!("/projects/{RID}/commits")).await;
|
let response = get(&app, format!("/projects/{RID}/commits")).await;
|
||||||
|
|
||||||
assert_eq!(response.status(), StatusCode::FOUND);
|
assert_eq!(response.status(), StatusCode::OK);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
response.json().await,
|
response.json().await,
|
||||||
json!({
|
json!({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue