chiark / gitweb /
update: include "What's New" texts when they are available
authorHans-Christoph Steiner <hans@eds.org>
Thu, 13 Apr 2017 21:36:46 +0000 (23:36 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Wed, 19 Apr 2017 08:05:24 +0000 (10:05 +0200)
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

fdroidserver/update.py
tests/metadata/info.guardianproject.urzip/en-US/changelogs/100.txt [new file with mode: 0644]
tests/metadata/info.guardianproject.urzip/en-US/full_description.txt [new file with mode: 0644]
tests/metadata/info.guardianproject.urzip/en-US/short_description.txt [new file with mode: 0644]
tests/metadata/info.guardianproject.urzip/en-US/title.txt [new file with mode: 0644]
tests/metadata/info.guardianproject.urzip/en-US/video.txt [new file with mode: 0644]
tests/update.TestCase

index d08df297681ec908368bb2ed8d891f63284ecd88..4a4da899969cd588b122012a448e223e641ede71 100644 (file)
@@ -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 (file)
index 0000000..29d6383
--- /dev/null
@@ -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 (file)
index 0000000..387b61d
--- /dev/null
@@ -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 (file)
index 0000000..306eb43
--- /dev/null
@@ -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 (file)
index 0000000..787215d
--- /dev/null
@@ -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 (file)
index 0000000..2b68b52
--- /dev/null
@@ -0,0 +1 @@
+video
index df85b27715e7de92b609c27f027dce9dddb4df95..ad85ebf8da5866c0b86674730727e4dd15dc966b 100755 (executable)
@@ -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')