aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <proyvind@moondrake.org>2016-07-22 16:48:40 +0200
committerPer Øyvind Karlsen <proyvind@moondrake.org>2016-07-22 16:48:40 +0200
commit88d54a58ef783282b4a522addda02e18aa31f1f3 (patch)
treed4506a7b73e66f5276b98439fa90775f68fae3b9 /MgaRepo
parent85bd0d837f3f001b61cba9e8e37257ee410dee32 (diff)
downloadmgarepo-88d54a58ef783282b4a522addda02e18aa31f1f3.tar
mgarepo-88d54a58ef783282b4a522addda02e18aa31f1f3.tar.gz
mgarepo-88d54a58ef783282b4a522addda02e18aa31f1f3.tar.bz2
mgarepo-88d54a58ef783282b4a522addda02e18aa31f1f3.tar.xz
mgarepo-88d54a58ef783282b4a522addda02e18aa31f1f3.zip
add support for cloning properly setup git-svn repos from github
Diffstat (limited to 'MgaRepo')
-rw-r--r--MgaRepo/GitHub.py20
-rw-r--r--MgaRepo/commands/github.py5
2 files changed, 23 insertions, 2 deletions
diff --git a/MgaRepo/GitHub.py b/MgaRepo/GitHub.py
index c077f7b..71f53d6 100644
--- a/MgaRepo/GitHub.py
+++ b/MgaRepo/GitHub.py
@@ -1,5 +1,6 @@
from MgaRepo import Error, config
from MgaRepo.rpmutil import detectVCS, get_pkg_tag, clone
+from MgaRepo.util import execcmd
from MgaRepo import layout
from MgaRepo.git import GIT
from MgaRepo.svn import SVN
@@ -58,7 +59,7 @@ class GitHub(object):
else:
raise Error(output)
- status, output = vcs.push(repository.full_name, "master", show=True)
+ status, output = vcs.push("--mirror", repository.full_name, show=True)
if status == 0:
print("Success!")
return True
@@ -69,3 +70,20 @@ class GitHub(object):
else:
raise Error("GitHub repository already exists at " + repository.html_url)
raise Error("GitHub import failed...")
+
+ def clone_repository(self, pkgname, target=None):
+ if not target:
+ target = pkgname
+ repository = self.repository_exists(pkgname)
+ if repository:
+ svnurl = layout.checkout_url(layout.package_url(pkgname))
+ if repository.permissions:
+ giturl = repository.ssh_url
+ else:
+ giturl = repository.git_url
+ execcmd(("git", "clone", "--mirror", giturl, os.path.join(target, ".git")), show=True)
+ git_svn = GIT(path=target, url=svnurl)
+ git_svn.init(svnurl, pkgname, branch="master", fullnames=True)
+
+ return True
+ raise Error("Repository %s doesn't exist!" % (self._organization.login+"/"+pkgname))
diff --git a/MgaRepo/commands/github.py b/MgaRepo/commands/github.py
index c2fd188..3d600bc 100644
--- a/MgaRepo/commands/github.py
+++ b/MgaRepo/commands/github.py
@@ -17,6 +17,9 @@ Examples:
mgarepo github import existingpkg
mgarepo github import svn://svn.mageia.org/svn/packages/cauldron/existingpkg
"""
+def github_clone(pkg, **kwargs):
+ github = GitHub()
+ github.clone_repository(pkg)
def github_import(target=".", **kwargs):
github = GitHub()
@@ -34,7 +37,7 @@ def parse_options():
opts.func = globals().get("github_"+args[0], None)
if args[0] == "import":
opts.target = args[1]
- elif args[0] == "delete":
+ elif args[0] == "delete" or args[0] == "clone":
opts.pkg = args[1]
else:
raise Error("invalid arguments: %s" % str(args))