Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sha based request in combination with hbs #1320

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions josh-proxy/src/bin/josh-proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1402,9 +1402,13 @@ async fn serve_query(
.unwrap(),
)?;

let commit_id = transaction_mirror
.repo()
.refname_to_id(&transaction_mirror.refname(&head_ref))?;
let commit_id = if let Ok(oid) = git2::Oid::from_str(&head_ref) {
oid
} else {
transaction_mirror
.repo()
.refname_to_id(&transaction_mirror.refname(&head_ref))?
};
let commit_id =
josh::filter_commit(&transaction, filter, commit_id, josh::filter::empty())?;

Expand Down
11 changes: 11 additions & 0 deletions tests/proxy/query.t
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Now render still works (used to fail if filtered previously)
param: 12345
sha: 890148bbaa6a797bac8aef672a437f2b08635f15
filter_sha: ffe8d082c1034053534ea8068f4205ac72a1098e

$ curl -s -i http://localhost:8002/real_repo.git?render=tmpl_file\&param_val=12345 | grep -v date:
HTTP/1.1 200 OK\r (esc)
content-type: text/plain\r (esc)
Expand All @@ -78,6 +79,16 @@ Now render still works (used to fail if filtered previously)
sha: 890148bbaa6a797bac8aef672a437f2b08635f15
filter_sha: ffe8d082c1034053534ea8068f4205ac72a1098e

$ curl -s http://localhost:8002/real_repo.git@refs/heads/master?render=tmpl_file\&param_val=12345 | grep -v date:
param: 12345
sha: 890148bbaa6a797bac8aef672a437f2b08635f15
filter_sha: ffe8d082c1034053534ea8068f4205ac72a1098e

$ curl -s http://localhost:8002/real_repo.git@890148bbaa6a797bac8aef672a437f2b08635f15?render=tmpl_file\&param_val=12345 | grep -v date:
param: 12345
sha: 890148bbaa6a797bac8aef672a437f2b08635f15
filter_sha: ffe8d082c1034053534ea8068f4205ac72a1098e

Graphql works
$ curl -s http://localhost:8002/real_repo.git?graphql=x.graphql
{
Expand Down
Loading