diff options
author | Ray Strode <rstrode@redhat.com> | 2016-12-05 15:20:15 +0000 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2016-12-05 17:33:19 +0000 |
commit | c2fd4d7a17769d396f197ca26c1c6c1d10db5cbd (patch) | |
tree | c0198f0d4582280ae07e102f1b74d024c448cbf3 | |
parent | 97a0d8b0d4819a4123a3895808aca9582967e01a (diff) |
post-receive-mirror-github: another nested repo fix
This way we can handle namespaces with hyphens in them.
-rwxr-xr-x | post-receive-mirror-github | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/post-receive-mirror-github b/post-receive-mirror-github index c7e13c5..ad2bd99 100755 --- a/post-receive-mirror-github +++ b/post-receive-mirror-github @@ -100,15 +100,23 @@ class GitHub: return name def get_repo_name (): - repo_name = "".join(os.getcwd ().split("/git/")[1:]).replace('/','-') + repo_namespace = os.getcwd ().split("/")[-2] + + if repo_namespace == "git": + repo_namespace = None + + repo_parts = "".join(os.getcwd ().split("/git/")[1:]).split('/') + + if repo_namespace and repo_parts[1].startswith(repo_namespace + '-'): + repo_parts[1] = repo_parts[1].replace(repo_namespace + '-', '', 1) + elif repo_namespace and repo_parts[1] == repo_namespace: + repo_parts.remove(repo_parts[1]) + + repo_name = "-".join(repo_parts) + if repo_name.endswith(".git"): repo_name = repo_name[0:-4] - parts = repo_name.split("-") - while len(parts) >= 2 and parts[0] == parts[1]: - parts.remove(parts[0]) - repo_name = "-".join(parts) - return repo_name def main (): |