aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo
diff options
context:
space:
mode:
Diffstat (limited to 'MgaRepo')
-rw-r--r--MgaRepo/GitHub.py3
-rw-r--r--MgaRepo/layout.py2
-rw-r--r--MgaRepo/rpmutil.py30
-rw-r--r--MgaRepo/vcsutil.py27
4 files changed, 33 insertions, 29 deletions
diff --git a/MgaRepo/GitHub.py b/MgaRepo/GitHub.py
index 71f53d6..74da43e 100644
--- a/MgaRepo/GitHub.py
+++ b/MgaRepo/GitHub.py
@@ -1,9 +1,10 @@
from MgaRepo import Error, config
-from MgaRepo.rpmutil import detectVCS, get_pkg_tag, clone
+from MgaRepo.rpmutil import get_pkg_tag, clone
from MgaRepo.util import execcmd
from MgaRepo import layout
from MgaRepo.git import GIT
from MgaRepo.svn import SVN
+from MgaRepo.vcsutil import detectVCS
from rpm import RPMTAG_SUMMARY, RPMTAG_URL
import github
import os
diff --git a/MgaRepo/layout.py b/MgaRepo/layout.py
index ce39eac..395e996 100644
--- a/MgaRepo/layout.py
+++ b/MgaRepo/layout.py
@@ -5,7 +5,7 @@ import urllib.parse
from MgaRepo import Error, config
from MgaRepo.svn import SVN
-from MgaRepo.rpmutil import detectVCS
+from MgaRepo.vcsutil import detectVCS
__all__ = ["package_url", "checkout_url", "repository_url", "get_url_revision"]
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()
diff --git a/MgaRepo/vcsutil.py b/MgaRepo/vcsutil.py
new file mode 100644
index 0000000..cf0237c
--- /dev/null
+++ b/MgaRepo/vcsutil.py
@@ -0,0 +1,27 @@
+from MgaRepo.git import GIT
+from MgaRepo.svn import SVN
+
+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)