aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <paul.sokolovsky@linaro.org>2016-04-07 15:18:27 +0300
committerPaul Sokolovsky <paul.sokolovsky@linaro.org>2016-04-07 15:18:27 +0300
commit330d80926cceaf5dbb028b214a9820bb0eb8c4fe (patch)
treef373411bb74ba137c402a7153a3f745c8cabbc1c
parentb6830d5c7e4e347e02d1f41ff64213fded656025 (diff)
git-gerrit-mirror: Allow to pick manifest from a mirrored repo.
Thus, it resolves issue with where seed manifest comes from, and how to keep it up to date. Change-Id: I9e0458a9120d2b72d8d4d405d367037ca180e3d5
-rwxr-xr-xgit-gerrit-mirror21
-rw-r--r--mirror.conf.sample9
2 files changed, 26 insertions, 4 deletions
diff --git a/git-gerrit-mirror b/git-gerrit-mirror
index cfee507..7c17c41 100755
--- a/git-gerrit-mirror
+++ b/git-gerrit-mirror
@@ -129,8 +129,21 @@ def scan_git_projects(basedir):
return git_repos
-def get_manifest_projects(manifest):
- dom = minidom.parse(manifest)
+def get_manifest_projects(host, manifest):
+ if manifest.startswith("mirror:"):
+ manifest = manifest.split(":", 1)[1]
+ manifest, rest = manifest.split("#", 1)
+ branch, fname = rest.split(";", 1)
+ manifest_repo = host_url_to_path(host) + "/" + manifest + ".git"
+ if not os.path.isdir(manifest_repo):
+ log.warn("Cannot get project list - manifest repo %s hasn't been mirrored yet", manifest_repo)
+ return []
+ f = os.popen("GIT_DIR=%s git show %s:%s" % (manifest_repo, branch, fname), "r")
+ data = f.read()
+ f.close()
+ dom = minidom.parseString(data)
+ else:
+ dom = minidom.parse(manifest)
return [p.getAttribute("name")
for p in dom.getElementsByTagName("project")]
@@ -196,10 +209,10 @@ def get_project_map_for_a_host(host):
if options.manifest:
print("Warning: global --manifest option is deprecated, "
"use per-host $manifest setting in mirror.conf")
- projects = get_manifest_projects(options.manifest)
+ projects = get_manifest_projects(host, options.manifest)
elif conf.get_var(host, "manifest"):
manifest = conf.get_var(host, "manifest")
- projects = get_manifest_projects(manifest)
+ projects = get_manifest_projects(host, manifest)
elif conf.get_var(host, "project_list"):
url = conf.get_var(host, "project_list")
projects = get_cached(get_url_project_list, (url,))
diff --git a/mirror.conf.sample b/mirror.conf.sample
index be6a1b5..ce2bc2b 100644
--- a/mirror.conf.sample
+++ b/mirror.conf.sample
@@ -41,6 +41,15 @@ $repo_root = /mnt/gerrit-git-snapshot/git
# be specified explicitly:
#platform/manifest = subtree/platform/manifest
+#[git://ultimate-android-tree.org]
+# If manual manifest mirroring doesn't cut, here's now a feature
+# to use manifest file from one of the repositories being mirrored,
+# so freshed manifest will be used automagically
+# Typical setup:
+#$manifest = mirror:platform/manifest#branch;default.xml
+#* = subtree/*
+#platform/manifest = subtree/platform/manifest
+
[git://android.git.kernel.org]
$active = false
$gerrit = review.source.android.com