mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 22:42:29 +03:00
metadata: fix crash if .fdroid.yml but its not a git repo
This commit is contained in:
parent
c2bc52dd85
commit
bb99986630
2 changed files with 18 additions and 2 deletions
|
@ -672,7 +672,7 @@ def parse_metadata(metadatapath):
|
||||||
# pylint: disable-next=no-member
|
# pylint: disable-next=no-member
|
||||||
except git.exc.InvalidGitRepositoryError:
|
except git.exc.InvalidGitRepositoryError:
|
||||||
logging.debug(
|
logging.debug(
|
||||||
_('Including metadata from {path}').format(metadata_in_repo)
|
_('Including metadata from {path}').format(path=metadata_in_repo)
|
||||||
)
|
)
|
||||||
app_in_repo = parse_metadata(metadata_in_repo)
|
app_in_repo = parse_metadata(metadata_in_repo)
|
||||||
for k, v in app_in_repo.items():
|
for k, v in app_in_repo.items():
|
||||||
|
|
|
@ -15,7 +15,7 @@ import textwrap
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from testcommon import TmpCwd
|
from testcommon import TmpCwd, mkdtemp
|
||||||
|
|
||||||
localmodule = Path(__file__).resolve().parent.parent
|
localmodule = Path(__file__).resolve().parent.parent
|
||||||
print('localmodule: ' + str(localmodule))
|
print('localmodule: ' + str(localmodule))
|
||||||
|
@ -40,10 +40,13 @@ class MetadataTest(unittest.TestCase):
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
self.basedir = localmodule / 'tests'
|
self.basedir = localmodule / 'tests'
|
||||||
os.chdir(self.basedir)
|
os.chdir(self.basedir)
|
||||||
|
self._td = mkdtemp()
|
||||||
|
self.testdir = self._td.name
|
||||||
fdroidserver.metadata.warnings_action = 'error'
|
fdroidserver.metadata.warnings_action = 'error'
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
# auto-generated dirs by functions, not tests, so they are not always cleaned up
|
# auto-generated dirs by functions, not tests, so they are not always cleaned up
|
||||||
|
self._td.cleanup()
|
||||||
try:
|
try:
|
||||||
os.rmdir("srclibs")
|
os.rmdir("srclibs")
|
||||||
except OSError:
|
except OSError:
|
||||||
|
@ -228,6 +231,19 @@ class MetadataTest(unittest.TestCase):
|
||||||
# yaml.register_class(metadata.Build)
|
# yaml.register_class(metadata.Build)
|
||||||
# yaml.dump(frommeta, fp)
|
# yaml.dump(frommeta, fp)
|
||||||
|
|
||||||
|
def test_dot_fdroid_yml_works_without_git(self):
|
||||||
|
"""Parsing should work if .fdroid.yml is present and it is not a git repo."""
|
||||||
|
os.chdir(self.testdir)
|
||||||
|
yml = Path('metadata/test.yml')
|
||||||
|
yml.parent.mkdir()
|
||||||
|
with yml.open('w') as fp:
|
||||||
|
fp.write('Repo: https://example.com/not/git/or/anything')
|
||||||
|
fdroid_yml = Path('build/test/.fdroid.yml')
|
||||||
|
fdroid_yml.parent.mkdir(parents=True)
|
||||||
|
with fdroid_yml.open('w') as fp:
|
||||||
|
fp.write('OpenCollective: test')
|
||||||
|
metadata.parse_metadata(yml) # should not throw an exception
|
||||||
|
|
||||||
def test_rewrite_yaml_fakeotaupdate(self):
|
def test_rewrite_yaml_fakeotaupdate(self):
|
||||||
with tempfile.TemporaryDirectory() as testdir:
|
with tempfile.TemporaryDirectory() as testdir:
|
||||||
testdir = Path(testdir)
|
testdir = Path(testdir)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue