Skip to content

Commit 42959a2

Browse files
Support '^' as character separating upstream revision
commit-id:f248d6a9
1 parent 9b77d84 commit 42959a2

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ lazy_static! {
4040

4141
josh::regex_parsed!(
4242
FilteredRepoUrl,
43-
r"(?P<api>/~/\w+)?(?P<upstream_repo>/[^:!]*[.]git)(?P<headref>@[^:!]*)?((?P<filter_spec>[:!].*)[.]git)?(?P<pathinfo>/.*)?(?P<rest>.*)",
43+
r"(?P<api>/~/\w+)?(?P<upstream_repo>/[^:!]*[.]git)(?P<headref>[\^@][^:!]*)?((?P<filter_spec>[:!].*)[.]git)?(?P<pathinfo>/.*)?(?P<rest>.*)",
4444
[api, upstream_repo, filter_spec, pathinfo, headref, rest]
4545
);
4646

@@ -718,7 +718,9 @@ fn is_repo_blocked(meta: &MetaConfig) -> bool {
718718
}
719719

720720
fn headref_or_default(headref: &str) -> String {
721-
let result = headref.trim_start_matches('@').to_owned();
721+
let result = headref
722+
.trim_start_matches(|char| char == '@' || char == '^')
723+
.to_owned();
722724

723725
if result.is_empty() {
724726
"HEAD".to_string()

tests/proxy/clone_sha.t

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,15 @@
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)
52+
$ git ls-remote http://localhost:8002/real_repo.git@bb282e9cdc1b972fffd08fd21eead43bc0c83cb8:/.git | tr '\t' ' '
53+
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8 HEAD
54+
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8 refs/heads/_bb282e9cdc1b972fffd08fd21eead43bc0c83cb8
55+
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8 refs/heads/master
56+
57+
$ git ls-remote http://localhost:8002/real_repo.git^bb282e9cdc1b972fffd08fd21eead43bc0c83cb8:/.git | tr '\t' ' '
58+
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8 HEAD
59+
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8 refs/heads/_bb282e9cdc1b972fffd08fd21eead43bc0c83cb8
60+
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8 refs/heads/master
5661

5762
$ git clone -q http://localhost:8002/real_repo.git@bb282e9cdc1b972fffd08fd21eead43bc0c83cb8:/.git full_repo
5863

0 commit comments

Comments
 (0)