httpd: Fix status code in commit history endpoint

Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Rūdolfs Ošiņš
2023-03-15 10:17:41 +01:00
committed by Alexis Sellier
parent 1c0dd54bbf
commit caa7078d62
+4 -8
View File
@@ -138,12 +138,12 @@ async fn history_handler(
per_page,
} = qs;
let (sha, fallback_to_head) = match parent {
Some(commit) => (commit, false),
let sha = match parent {
Some(commit) => commit,
None => {
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()?,
});
if fallback_to_head {
return Ok::<_, Error>((StatusCode::FOUND, Json(response)));
}
Ok::<_, Error>((StatusCode::OK, Json(response)))
}
@@ -689,7 +685,7 @@ mod routes {
let app = super::router(test::seed(tmp.path()));
let response = get(&app, format!("/projects/{RID}/commits")).await;
assert_eq!(response.status(), StatusCode::FOUND);
assert_eq!(response.status(), StatusCode::OK);
assert_eq!(
response.json().await,
json!({