Skip to content

Commit 8810504

Browse files
Fix sha based request in combination with hbs (#1320)
The case where a sha was passed instead of a ref was not handled in the code for rendering hbs files. Change: fix-sha-hbs
1 parent fa8a7e0 commit 8810504

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

josh-proxy/src/bin/josh-proxy.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,9 +1402,13 @@ async fn serve_query(
14021402
.unwrap(),
14031403
)?;
14041404

1405-
let commit_id = transaction_mirror
1406-
.repo()
1407-
.refname_to_id(&transaction_mirror.refname(&head_ref))?;
1405+
let commit_id = if let Ok(oid) = git2::Oid::from_str(&head_ref) {
1406+
oid
1407+
} else {
1408+
transaction_mirror
1409+
.repo()
1410+
.refname_to_id(&transaction_mirror.refname(&head_ref))?
1411+
};
14081412
let commit_id =
14091413
josh::filter_commit(&transaction, filter, commit_id, josh::filter::empty())?;
14101414

tests/proxy/query.t

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Now render still works (used to fail if filtered previously)
6969
param: 12345
7070
sha: 890148bbaa6a797bac8aef672a437f2b08635f15
7171
filter_sha: ffe8d082c1034053534ea8068f4205ac72a1098e
72+
7273
$ curl -s -i http://localhost:8002/real_repo.git?render=tmpl_file\&param_val=12345 | grep -v date:
7374
HTTP/1.1 200 OK\r (esc)
7475
content-type: text/plain\r (esc)
@@ -78,6 +79,16 @@ Now render still works (used to fail if filtered previously)
7879
sha: 890148bbaa6a797bac8aef672a437f2b08635f15
7980
filter_sha: ffe8d082c1034053534ea8068f4205ac72a1098e
8081

82+
$ curl -s http://localhost:8002/real_repo.git@refs/heads/master?render=tmpl_file\&param_val=12345 | grep -v date:
83+
param: 12345
84+
sha: 890148bbaa6a797bac8aef672a437f2b08635f15
85+
filter_sha: ffe8d082c1034053534ea8068f4205ac72a1098e
86+
87+
$ curl -s http://localhost:8002/real_repo.git@890148bbaa6a797bac8aef672a437f2b08635f15?render=tmpl_file\&param_val=12345 | grep -v date:
88+
param: 12345
89+
sha: 890148bbaa6a797bac8aef672a437f2b08635f15
90+
filter_sha: ffe8d082c1034053534ea8068f4205ac72a1098e
91+
8192
Graphql works
8293
$ curl -s http://localhost:8002/real_repo.git?graphql=x.graphql
8394
{

0 commit comments

Comments
 (0)