From: Hans-Christoph Steiner Date: Thu, 13 Apr 2017 21:36:46 +0000 (+0200) Subject: update: include "What's New" texts when they are available X-Git-Tag: 0.8~74^2~4 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=9589d13ef2e10731771d4ce3ce8f16853ac80edc;p=fdroidserver.git update: include "What's New" texts when they are available This uses the "What's New" entry for the CurrentVersionCode and includes it as the current WhatsNew metadata for the App class. Things like fastlane supply and Google Play support a "What's New" entry per-APK, but fdroidclient does not current use anything but the current version of this data. Right now, it seems we probably only want to have the latest WhatsNew in the index to save space. In theory, we could make the WhatsNew data structure follow the structure of fastlane/Play, but that would quite a bit of complexity for something that might never be used. fdroidclient#910 --- diff --git a/fdroidserver/update.py b/fdroidserver/update.py index d08df297..4a4da899 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -619,6 +619,10 @@ def copy_triple_t_store_metadata(apps): _set_localized_text_entry(app, locale, 'Video', os.path.join(root, f)) continue + elif f == 'whatsnew': + _set_localized_text_entry(app, segments[-1], 'WhatsNew', + os.path.join(root, f)) + continue base, extension = common.get_extension(f) dirname = os.path.basename(root) @@ -648,6 +652,18 @@ def insert_localized_app_metadata(apps): repo/packageName/locale/phoneScreenshots/1.png repo/packageName/locale/phoneScreenshots/2.png + The changelog files must be text files named with the versionCode + ending with ".txt" and must be in the following layout: + https://github.com/fastlane/fastlane/blob/1.109.0/supply/README.md#changelogs-whats-new + + repo/packageName/locale/changelogs/12345.txt + + This will scan the each app's source repo then the metadata/ dir + for these standard locations of changelog files. If it finds + them, they will be added to the dict of all packages, with the + versions in the metadata/ folder taking precendence over the what + is in the app's source repo. + Where "packageName" is the app's packageName and "locale" is the locale of the graphics, e.g. what language they are in, using the IETF RFC5646 format (en-US, fr-CA, es-MX, etc). @@ -657,6 +673,7 @@ def insert_localized_app_metadata(apps): of graphic and screenshot files. If it finds them, it will copy them into the repo. The fastlane files follow this pattern: https://github.com/fastlane/fastlane/blob/1.109.0/supply/README.md#images-and-screenshots + """ sourcedirs = glob.glob(os.path.join('build', '[A-Za-z]*', 'fastlane', 'metadata', 'android', '[a-z][a-z][A-Z-.@]*')) @@ -690,6 +707,10 @@ def insert_localized_app_metadata(apps): _set_localized_text_entry(apps[packageName], locale, 'Video', os.path.join(root, f)) continue + elif f == str(apps[packageName]['CurrentVersionCode']) + '.txt': + _set_localized_text_entry(apps[packageName], segments[-2], 'WhatsNew', + os.path.join(root, f)) + continue base, extension = common.get_extension(f) if base in GRAPHIC_NAMES and extension in ALLOWED_EXTENSIONS: diff --git a/tests/metadata/info.guardianproject.urzip/en-US/changelogs/100.txt b/tests/metadata/info.guardianproject.urzip/en-US/changelogs/100.txt new file mode 100644 index 00000000..29d6383b --- /dev/null +++ b/tests/metadata/info.guardianproject.urzip/en-US/changelogs/100.txt @@ -0,0 +1 @@ +100 diff --git a/tests/metadata/info.guardianproject.urzip/en-US/full_description.txt b/tests/metadata/info.guardianproject.urzip/en-US/full_description.txt new file mode 100644 index 00000000..387b61d2 --- /dev/null +++ b/tests/metadata/info.guardianproject.urzip/en-US/full_description.txt @@ -0,0 +1 @@ +full description diff --git a/tests/metadata/info.guardianproject.urzip/en-US/short_description.txt b/tests/metadata/info.guardianproject.urzip/en-US/short_description.txt new file mode 100644 index 00000000..306eb438 --- /dev/null +++ b/tests/metadata/info.guardianproject.urzip/en-US/short_description.txt @@ -0,0 +1 @@ +short description diff --git a/tests/metadata/info.guardianproject.urzip/en-US/title.txt b/tests/metadata/info.guardianproject.urzip/en-US/title.txt new file mode 100644 index 00000000..787215d4 --- /dev/null +++ b/tests/metadata/info.guardianproject.urzip/en-US/title.txt @@ -0,0 +1 @@ +title diff --git a/tests/metadata/info.guardianproject.urzip/en-US/video.txt b/tests/metadata/info.guardianproject.urzip/en-US/video.txt new file mode 100644 index 00000000..2b68b523 --- /dev/null +++ b/tests/metadata/info.guardianproject.urzip/en-US/video.txt @@ -0,0 +1 @@ +video diff --git a/tests/update.TestCase b/tests/update.TestCase index df85b277..ad85ebf8 100755 --- a/tests/update.TestCase +++ b/tests/update.TestCase @@ -24,6 +24,44 @@ from fdroidserver.common import FDroidPopen class UpdateTest(unittest.TestCase): '''fdroid update''' + def testInsertStoreMetadata(self): + config = dict() + fdroidserver.common.fill_config_defaults(config) + config['accepted_formats'] = ('txt', 'yml') + fdroidserver.update.config = config + fdroidserver.update.options = fdroidserver.common.options + os.chdir(os.path.join(localmodule, 'tests')) + + apps = dict() + for packageName in ('info.guardianproject.urzip', 'org.videolan.vlc', 'obb.mainpatch.current'): + apps[packageName] = dict() + apps[packageName]['id'] = packageName + apps[packageName]['CurrentVersionCode'] = 0xcafebeef + apps['info.guardianproject.urzip']['CurrentVersionCode'] = 100 + fdroidserver.update.insert_localized_app_metadata(apps) + + self.assertEqual(3, len(apps)) + for packageName, app in apps.items(): + self.assertTrue('localized' in app) + self.assertTrue('en-US' in app['localized']) + self.assertEqual(1, len(app['localized'])) + if packageName == 'info.guardianproject.urzip': + self.assertEqual(5, len(app['localized']['en-US'])) + self.assertEqual('full description\n', app['localized']['en-US']['Description']) + self.assertEqual('title\n', app['localized']['en-US']['Name']) + self.assertEqual('short description\n', app['localized']['en-US']['Summary']) + self.assertEqual('video\n', app['localized']['en-US']['Video']) + self.assertEqual('100\n', app['localized']['en-US']['WhatsNew']) + elif packageName == 'org.videolan.vlc': + self.assertEqual('icon.png', app['localized']['en-US']['icon']) + self.assertEqual(9, len(app['localized']['en-US']['phoneScreenshots'])) + self.assertEqual(15, len(app['localized']['en-US']['sevenInchScreenshots'])) + elif packageName == 'obb.mainpatch.current': + self.assertEqual('icon.png', app['localized']['en-US']['icon']) + self.assertEqual('featureGraphic.png', app['localized']['en-US']['featureGraphic']) + self.assertEqual(1, len(app['localized']['en-US']['phoneScreenshots'])) + self.assertEqual(1, len(app['localized']['en-US']['sevenInchScreenshots'])) + def javagetsig(self, apkfile): getsig_dir = os.path.join(os.path.dirname(__file__), 'getsig') if not os.path.exists(getsig_dir + "/getsig.class"): @@ -84,7 +122,7 @@ class UpdateTest(unittest.TestCase): self.assertIsNone(pysig, "python sig should be None: " + str(sig)) def testScanApksAndObbs(self): - os.chdir(os.path.dirname(__file__)) + os.chdir(os.path.join(localmodule, 'tests')) if os.path.basename(os.getcwd()) != 'tests': raise Exception('This test must be run in the "tests/" subdir') @@ -131,7 +169,7 @@ class UpdateTest(unittest.TestCase): self.assertIsNone(apk.get('obbPatchFile')) def test_scan_invalid_apk(self): - os.chdir(os.path.dirname(__file__)) + os.chdir(os.path.join(localmodule, 'tests')) if os.path.basename(os.getcwd()) != 'tests': raise Exception('This test must be run in the "tests/" subdir')