aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo/rpmutil.py
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <proyvind@moondrake.org>2016-10-04 04:30:06 +0000
committerPer Øyvind Karlsen <proyvind@moondrake.org>2016-10-04 04:30:06 +0000
commitc02b61213c742df7eae63349d0a807c417adb9af (patch)
treecb51d67c40e741e53a90681862c80afac83e6194 /MgaRepo/rpmutil.py
parent14d5c0398fa649f03b6e0f43ab811594890a9a91 (diff)
downloadmgarepo-c02b61213c742df7eae63349d0a807c417adb9af.tar
mgarepo-c02b61213c742df7eae63349d0a807c417adb9af.tar.gz
mgarepo-c02b61213c742df7eae63349d0a807c417adb9af.tar.bz2
mgarepo-c02b61213c742df7eae63349d0a807c417adb9af.tar.xz
mgarepo-c02b61213c742df7eae63349d0a807c417adb9af.zip
move detectVCS() to separate module to prevent import order
Diffstat (limited to 'MgaRepo/rpmutil.py')
-rw-r--r--MgaRepo/rpmutil.py30
1 files changed, 3 insertions, 27 deletions
diff --git a/MgaRepo/rpmutil.py b/MgaRepo/rpmutil.py
index 08fcfd9..0fe6f81 100644
--- a/MgaRepo/rpmutil.py
+++ b/MgaRepo/rpmutil.py
@@ -1,9 +1,10 @@
from MgaRepo import Error, config
from MgaRepo import mirror, layout, log, binrepo
-from MgaRepo.git import GIT
-from MgaRepo.svn import SVN
from MgaRepo.simplerpm import SRPM
from MgaRepo.util import execcmd, CommandError
+from MgaRepo.git import GIT
+from MgaRepo.svn import SVN
+from MgaRepo.vcsutil import detectVCS
from MgaRepo.command import default_parent
import rpm
import urllib.parse
@@ -14,31 +15,6 @@ import glob
import sys
import os
-def detectVCS(url):
- if ':' in url:
- protocol,uri = url.split(":")
- if "svn" in protocol:
- return SVN(url=url)
- elif "git" in protocol:
- return GIT(url=url)
- elif "http" in protocol:
- if uri.endswith(".git"):
- return GIT(url=url)
- elif "svn" in uri:
- return SVN(url=url)
- raise Error("Unknown protocol %s for %s" % (protocol, url))
- elif os.path.exists(url) and os.path.isdir(url):
- while True:
- url = os.path.abspath(url)
- for vcs in (SVN, GIT):
- vcsdir = os.path.join(url, vcs.vcs_dirname)
- if os.path.exists(vcsdir) and os.path.isdir(vcsdir):
- return vcs(path=url)
- url = os.path.dirname(url)
- if url == "/":
- break
- raise Error("No supported repository found at path: %s" % url)
-
def get_spec(pkgdirurl, targetdir=".", submit=False):
svn = detectVCS(pkgdirurl)
tmpdir = tempfile.mktemp()