Skip to content

Commit

Permalink
FIX: Git command supports commit names that contains /
Browse files Browse the repository at this point in the history
  • Loading branch information
BojanG99 committed Dec 17, 2024
1 parent 98b132f commit 71ccad2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/server/api/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,7 @@ struct Info {
/// Return the content in the stelae archive in the `{namespace}/{name}`
/// repo at the `commitish` commit at the `remainder` path.
/// Return 404 if any are not found or there are any errors.
#[route(
"/{namespace}/{name}/{commitish}{remainder:/+([^{}]*?)?/*}",
method = "GET",
method = "HEAD"
)]
#[route("/{namespace}/{name}", method = "GET", method = "HEAD")]
#[tracing::instrument(name = "Retrieving a Git blob", skip(path, data, info))]
#[expect(
clippy::future_not_send,
Expand All @@ -355,10 +351,10 @@ async fn get_blob(
info: web::Query<Info>,
data: web::Data<AppState>,
) -> impl Responder {
let (namespace, name /* , commitish, remainder*/) = path.into_inner();
let (namespace, name) = path.into_inner();
let info_struct: Info = info.into_inner();
let commitish = info_struct.commitish;
let remainder = info_struct.remainder.unwrap_or_else(|| "".to_string());
let remainder = info_struct.remainder.unwrap_or_default();
let archive_path = &data.archive_path;
let blob = Repo::find_blob(archive_path, &namespace, &name, &remainder, &commitish);
let blob_path = clean_path(&remainder);
Expand All @@ -370,7 +366,7 @@ async fn get_blob(
}

/// A centralised place to match potentially unsafe internal errors to safe user-facing error responses
#[allow(clippy::wildcard_enum_match_arm)]
#[expect(clippy::wildcard_enum_match_arm, reason = "Allows _ for enum matching")]
#[tracing::instrument(name = "Error with Git blob request", skip(error, namespace, name))]
fn blob_error_response(error: &anyhow::Error, namespace: &str, name: &str) -> HttpResponse {
tracing::error!("{error}",);
Expand Down
3 changes: 3 additions & 0 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ impl Global for TestAppState {
fn db(&self) -> &db::DatabaseConnection {
unimplemented!()
}
fn archive_path(&self) -> &PathBuf {
unimplemented!()
}
}

pub async fn initialize_app(
Expand Down

0 comments on commit 71ccad2

Please sign in to comment.