diff options
Diffstat (limited to 'git-gerrit-mirror')
-rwxr-xr-x | git-gerrit-mirror | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/git-gerrit-mirror b/git-gerrit-mirror index c0b0d3e..4bc70d0 100755 --- a/git-gerrit-mirror +++ b/git-gerrit-mirror @@ -241,7 +241,7 @@ def clone_repos(host, basedir, projects): log.info("cd'ing to %s", dir) os.chdir(dir) # --depth=1 - cmd = "git clone --mirror %s/%s.git" % (host, p) + cmd = "git clone --mirror %s/%s.git" % (clean_host(host), p) run_command(cmd) os.chdir(basedir) new_repos.append(p + '.git') @@ -293,9 +293,20 @@ def handle_updated_repos(conf, host, repos): def host_url_to_path(host): + "Convert host url from config to mirror dir path." + parts = host.rsplit("#", 1) + host = parts[0] host_p = urlparse.urlparse(host.rstrip("/")) path_adjusted = host_p.path.replace("/", "__") - return options.mirror_dir + "/" + host_p.netloc + path_adjusted + ret = options.mirror_dir + "/" + host_p.netloc + path_adjusted + if len(parts) > 1: + ret += "#" + parts[1] + return ret + + +def clean_host(host): + "Split any #N trailers from config host url." + return host.rsplit("#", 1)[0] def check_args(optparser, args, expected): |