aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <paul.sokolovsky@linaro.org>2016-04-06 23:29:22 +0300
committerPaul Sokolovsky <paul.sokolovsky@linaro.org>2016-04-06 23:29:22 +0300
commit7aad6d240e2041c79944c52a1c12735c53114dc1 (patch)
treef88e832c6e231b3b94779ea613d530ead4fedbc6
parentd96017168ebc38c4a9b44e15edf1aa96008e28d1 (diff)
git-gerrit-mirror: Allow to create more than one mirror of the same host.
Sometimes different downstream projects may need different mirrors of the same upstream tree. So, just allow to have different mirroring entries for the same host, differentiated with "#slug". Change-Id: I8a2edd0a58e22965ab896d3c5839623b0f844840
-rwxr-xr-xgit-gerrit-mirror15
-rw-r--r--mirror.conf.sample5
2 files changed, 18 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):
diff --git a/mirror.conf.sample b/mirror.conf.sample
index c40170d..be6a1b5 100644
--- a/mirror.conf.sample
+++ b/mirror.conf.sample
@@ -73,6 +73,11 @@ platform/hardware/ti/domx = platform/hardware/ti/domx-omapzoom
[https://github.com]
msg555/PowerTutor = platform/packages/apps/PowerTutor
+# Sometimes you need to create different mirrors of the same server.
+# Just append '#<slug>':
+[https://github.com#2]
+msg555/PowerTutor = platform2/packages/apps/PowerTutor
+
# [git://igloocommunity.org]
# git/android/platform/vendor/st-ericsson/multimedia/linux/b2r2lib = platform/vendor/st-ericsson/multimedia/linux/b2r2lib