mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-01 00:30:13 +02:00
Merge branch 'getvcs-pathlib-fix' into 'master'
handle str and pathlib.Path in getvcs() See merge request fdroid/fdroidserver!1311
This commit is contained in:
commit
c78aeb3947
@ -962,6 +962,11 @@ def setup_vcs(app):
|
||||
|
||||
|
||||
def getvcs(vcstype, remote, local):
|
||||
"""Return a vcs instance based on the arguments.
|
||||
|
||||
remote and local can be either a string or a pathlib.Path
|
||||
|
||||
"""
|
||||
if vcstype == 'git':
|
||||
return vcs_git(remote, local)
|
||||
if vcstype == 'git-svn':
|
||||
@ -971,7 +976,7 @@ def getvcs(vcstype, remote, local):
|
||||
if vcstype == 'bzr':
|
||||
return vcs_bzr(remote, local)
|
||||
if vcstype == 'srclib':
|
||||
if local != Path('build', 'srclib', remote):
|
||||
if str(local) != os.path.join('build', 'srclib', str(remote)):
|
||||
raise VCSException("Error: srclib paths are hard-coded!")
|
||||
return getsrclib(remote, os.path.join('build', 'srclib'), raw=True)
|
||||
if vcstype == 'svn':
|
||||
@ -1989,13 +1994,18 @@ def getsrclib(spec, srclib_dir, basepath=False,
|
||||
build=None):
|
||||
"""Get the specified source library.
|
||||
|
||||
Returns the path to it. Normally this is the path to be used when
|
||||
Return the path to it. Normally this is the path to be used when
|
||||
referencing it, which may be a subdirectory of the actual project. If
|
||||
you want the base directory of the project, pass 'basepath=True'.
|
||||
|
||||
spec and srclib_dir are both strings, not pathlib.Path.
|
||||
"""
|
||||
number = None
|
||||
subdir = None
|
||||
if not isinstance(spec, str):
|
||||
spec = str(spec)
|
||||
if not isinstance(srclib_dir, str):
|
||||
spec = str(srclib_dir)
|
||||
if raw:
|
||||
name = spec
|
||||
ref = None
|
||||
|
@ -58,6 +58,7 @@ class CommonTest(unittest.TestCase):
|
||||
fdroidserver.common.config = None
|
||||
fdroidserver.common.options = mock.Mock()
|
||||
fdroidserver.common.options.verbose = False
|
||||
fdroidserver.metadata.srclibs = None
|
||||
self._td = mkdtemp()
|
||||
self.testdir = self._td.name
|
||||
|
||||
@ -412,6 +413,47 @@ class CommonTest(unittest.TestCase):
|
||||
vcs1 = fdroidserver.common.getvcs('git', git_url, gitrepo)
|
||||
vcs1.gotorevision('0.3', refresh=False)
|
||||
|
||||
def test_setup_vcs_srclib(self):
|
||||
app = fdroidserver.metadata.App(
|
||||
{
|
||||
'RepoType': 'srclib',
|
||||
'Repo': 'TransportsRennes',
|
||||
}
|
||||
)
|
||||
srclib = {
|
||||
'RepoType': 'git',
|
||||
'Repo': 'https://github.com/ybonnel/TransportsRennes',
|
||||
}
|
||||
fdroidserver.metadata.srclibs = {'TransportsRennes': srclib}
|
||||
vcs, build_dir = fdroidserver.common.setup_vcs(app)
|
||||
self.assertIsNotNone(vcs)
|
||||
self.assertEqual(build_dir, Path('build/srclib/TransportsRennes'))
|
||||
|
||||
def test_getvcs_srclib(self):
|
||||
vcstype = 'srclib'
|
||||
remote = 'TransportsRennes'
|
||||
local = 'build/srclib/' + remote
|
||||
fdroidserver.metadata.srclibs = {
|
||||
remote: {
|
||||
'RepoType': 'git',
|
||||
'Repo': 'https://github.com/ybonnel/TransportsRennes',
|
||||
}
|
||||
}
|
||||
self.assertIsNotNone(fdroidserver.common.getvcs(vcstype, remote, local))
|
||||
self.assertIsNotNone(fdroidserver.common.getvcs(vcstype, Path(remote), local))
|
||||
self.assertIsNotNone(fdroidserver.common.getvcs(vcstype, remote, Path(local)))
|
||||
self.assertIsNotNone(fdroidserver.common.getvcs(
|
||||
vcstype, Path(remote), Path(local)
|
||||
))
|
||||
with self.assertRaises(VCSException):
|
||||
fdroidserver.common.getvcs(vcstype, remote, 'bad')
|
||||
with self.assertRaises(VCSException):
|
||||
fdroidserver.common.getvcs(vcstype, remote, Path('bad'))
|
||||
with self.assertRaises(VCSException):
|
||||
fdroidserver.common.getvcs(vcstype, Path(remote), 'bad')
|
||||
with self.assertRaises(VCSException):
|
||||
fdroidserver.common.getvcs(vcstype, Path(remote), Path('bad'))
|
||||
|
||||
def test_fdroid_popen_stderr_redirect(self):
|
||||
config = dict()
|
||||
fdroidserver.common.fill_config_defaults(config)
|
||||
@ -2315,7 +2357,7 @@ class CommonTest(unittest.TestCase):
|
||||
fdroidserver.common.fill_config_defaults(config)
|
||||
java_paths = []
|
||||
# use presence of javac to make sure its JDK not just JRE
|
||||
for f in glob.glob('/usr/lib/jvm/java-*-openjdk-amd64/bin/javac'):
|
||||
for f in glob.glob('/usr/lib/jvm/java-*-openjdk-*/bin/javac'):
|
||||
jdk = os.path.dirname(os.path.dirname(f))
|
||||
if not os.path.islink(jdk):
|
||||
java_paths.append(jdk)
|
||||
|
Loading…
Reference in New Issue
Block a user