Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
httpd: Fix status code in commit history endpoint
Rūdolfs Ošiņš committed 3 years ago
commit caa7078d627db5c10a01d9decc29ae6d29fa6a71
parent 1c0dd54bbf0747dceaaf3a17424c2315d9c918be
1 file changed +4 -8
modified radicle-httpd/src/api/v1/projects.rs
@@ -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!({