Skip to content

Commit ea1f814

Browse files
Handle @sha urls by creating magic ref (#690)
The @Rev url syntax did not work if rev was specified as a sha. This was because there was no ref for the symref HEAD to point to. Now a fake ref is created for that purpose.
1 parent 6f0f5de commit ea1f814

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,23 @@ async fn do_filter(
295295
)?;
296296
}
297297

298-
from_to.push((
299-
format!(
300-
"refs/josh/upstream/{}/{}",
301-
&josh::to_ns(&upstream_repo),
302-
headref
303-
),
304-
temp_ns.reference(&headref),
305-
));
306-
307298
let mut headref = headref;
308299

300+
if headref.starts_with("refs/") || headref == "HEAD" {
301+
from_to.push((
302+
format!(
303+
"refs/josh/upstream/{}/{}",
304+
&josh::to_ns(&upstream_repo),
305+
headref
306+
),
307+
temp_ns.reference(&headref),
308+
));
309+
} else {
310+
let headsha = headref.clone();
311+
headref = format!("refs/heads/_{}", &headref);
312+
from_to.push((headsha, temp_ns.reference(&headref)));
313+
}
314+
309315
josh::filter_refs(&transaction, filter, &from_to, josh::filter::empty())?;
310316
if headref == "HEAD" {
311317
headref = heads_map

tests/proxy/clone_sha.t

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949

5050
$ cd ${TESTTMP}
5151

52+
$ git ls-remote http://localhost:8002/real_repo.git@bb282e9cdc1b972fffd08fd21eead43bc0c83cb8:/.git
53+
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8\tHEAD (esc)
54+
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8\trefs/heads/_bb282e9cdc1b972fffd08fd21eead43bc0c83cb8 (esc)
55+
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8\trefs/heads/master (esc)
56+
5257
$ git clone -q http://localhost:8002/real_repo.git@bb282e9cdc1b972fffd08fd21eead43bc0c83cb8:/.git full_repo
5358

5459
$ cd full_repo

0 commit comments

Comments
 (0)