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-14 17:17:20 +01:00 committed by Alexis Sellier
parent de8e92d48c
commit fdd6bca311
No known key found for this signature in database
1 changed files with 4 additions and 8 deletions

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!({