Skip to content

Commit

Permalink
Support '^' as character separating upstream revision
Browse files Browse the repository at this point in the history
commit-id:f248d6a9
  • Loading branch information
vlad-ivanov-name committed Dec 6, 2022
1 parent 9b77d84 commit 42959a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions josh-proxy/src/bin/josh-proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ lazy_static! {

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

Expand Down Expand Up @@ -718,7 +718,9 @@ fn is_repo_blocked(meta: &MetaConfig) -> bool {
}

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

if result.is_empty() {
"HEAD".to_string()
Expand Down
13 changes: 9 additions & 4 deletions tests/proxy/clone_sha.t
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@

$ cd ${TESTTMP}

$ git ls-remote http://localhost:8002/real_repo.git@bb282e9cdc1b972fffd08fd21eead43bc0c83cb8:/.git
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8\tHEAD (esc)
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8\trefs/heads/_bb282e9cdc1b972fffd08fd21eead43bc0c83cb8 (esc)
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8\trefs/heads/master (esc)
$ git ls-remote http://localhost:8002/real_repo.git@bb282e9cdc1b972fffd08fd21eead43bc0c83cb8:/.git | tr '\t' ' '
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8 HEAD
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8 refs/heads/_bb282e9cdc1b972fffd08fd21eead43bc0c83cb8
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8 refs/heads/master

$ git ls-remote http://localhost:8002/real_repo.git^bb282e9cdc1b972fffd08fd21eead43bc0c83cb8:/.git | tr '\t' ' '
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8 HEAD
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8 refs/heads/_bb282e9cdc1b972fffd08fd21eead43bc0c83cb8
bb282e9cdc1b972fffd08fd21eead43bc0c83cb8 refs/heads/master

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

Expand Down

0 comments on commit 42959a2

Please sign in to comment.