diff --git a/fdroidserver/import.py b/fdroidserver/import.py index 6d729646..792f0f19 100644 --- a/fdroidserver/import.py +++ b/fdroidserver/import.py @@ -227,11 +227,11 @@ def main(): if local_metadata_files != []: raise FDroidException(_("This repo already has local metadata: %s") % local_metadata_files[0]) + build = metadata.Build() if options.url is None and os.path.isdir('.git'): app.AutoName = os.path.basename(os.getcwd()) app.RepoType = 'git' - build = metadata.Build() root_dir = get_subdir(os.getcwd()) if os.path.exists('build.gradle'): build.gradle = ['yes'] @@ -250,7 +250,6 @@ def main(): write_local_file = True elif options.url: root_dir, build_dir = get_metadata_from_url(app, options.url) - build = metadata.Build() build.commit = '?' build.disable = 'Generated by import.py - check/set version fields and commit id' write_local_file = False @@ -286,8 +285,8 @@ def main(): raise FDroidException("Package " + package + " already exists") # Create a build line... - build.versionName = versionName or '?' - build.versionCode = versionCode or '?' + build.versionName = versionName or 'Unknown' + build.versionCode = versionCode or '0' # TODO heinous but this is still a str if options.subdir: build.subdir = options.subdir if options.license: diff --git a/tests/metadata.TestCase b/tests/metadata.TestCase index c8f8b283..d4a741c8 100755 --- a/tests/metadata.TestCase +++ b/tests/metadata.TestCase @@ -165,7 +165,7 @@ class MetadataTest(unittest.TestCase): with self.assertRaises(MetaDataException): fdroidserver.metadata.parse_yaml_metadata(mf, {}) - def test_write_yaml_with_allow_placeholder_values(self): + def test_write_yaml_with_placeholder_values(self): mf = io.StringIO() app = fdroidserver.metadata.App() @@ -177,15 +177,14 @@ class MetadataTest(unittest.TestCase): app.AutoUpdateMode = 'None' app.UpdateCheckMode = 'Tags' build = fdroidserver.metadata.Build() - build.versionCode = 'Unknown' - build.versionName = 'Unknown' + build.versionName = 'Unknown' # taken from fdroidserver/import.py + build.versionCode = '0' # taken from fdroidserver/import.py build.disable = 'Generated by import.py ...' build.commit = 'Unknown' build.gradle = [True] app.builds = [build] - fdroidserver.metadata.write_yaml(mf, app, - allow_placeholder_values=True) + fdroidserver.metadata.write_yaml(mf, app) mf.seek(0) self.assertEqual(mf.read(), textwrap.dedent("""\ @@ -200,7 +199,7 @@ class MetadataTest(unittest.TestCase): Builds: - versionName: Unknown - versionCode: '?' + versionCode: 0 disable: Generated by import.py ... commit: Unknown gradle: @@ -221,4 +220,4 @@ if __name__ == "__main__": newSuite = unittest.TestSuite() newSuite.addTest(unittest.makeSuite(MetadataTest)) - unittest.main(failfast=False) + unittest.main(failfast=True)