chiark / gitweb /
New Update Check Mode: RepoTrunk
authorDaniel Martí <mvdan@mvdan.cc>
Thu, 17 Oct 2013 21:27:55 +0000 (23:27 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Thu, 17 Oct 2013 21:27:55 +0000 (23:27 +0200)
docs/fdroid.texi
fdroidserver/checkupdates.py
fdroidserver/common.py

index 08931c3cb5fd805837350f85c5cbd72cba6032e2..202728d28050b50f594339f2be1f5e79d417088b 100644 (file)
@@ -1091,6 +1091,13 @@ in place of the default one.  The default values are "master" for git,
 On the other hand, branch support hasn't been implemented yet in bzr and svn, 
 but RepoManifest may still be used without it.
 @item
+@code{RepoTrunk} - For svn and git-svn repositories, especially those who
+don't have a bundled AndroidManifest.xml file, the Tags and RepoManifest
+checks will not work, since there is no version information to obtain. But,
+for those apps who automate their build process with the commit ref that HEAD
+points to, RepoTrunk will set the Current Version and Current Version Code to
+that number.
+@item
 @code{Tags} - The AndroidManifest.xml file in all tagged revisions in the
 source repository is checked, looking for the highest version code. The
 appropriateness of this method depends on the development process used by the
index b43a772a76605a4ddb75b899e08540785fb15d61..1ffec342d8680c8341c6b1052d617e575efdeff5 100644 (file)
@@ -203,6 +203,35 @@ def check_repomanifest(app, sdk_path, branch=None):
         msg = "Could not scan app %s due to unknown error: %s" % (app['id'], traceback.format_exc())
         return (None, msg)
 
+def check_repotrunk(app, sdk_path, branch=None):
+
+    try:
+        if app['Repo Type'] == 'srclib':
+            build_dir = os.path.join('build', 'srclib', app['Repo'])
+            repotype = common.getsrclibvcs(app['Repo'])
+        else:
+            build_dir = os.path.join('build/', app['id'])
+            repotype = app['Repo Type']
+
+        if repotype not in ('svn', 'git-svn'):
+            return (None, 'RepoTrunk update mode only makes sense in svn and git-svn repositories')
+
+        # Set up vcs interface and make sure we have the latest code...
+        vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir, sdk_path)
+
+        vcs.gotorevision(None)
+
+        ref = vcs.getref()
+        return (ref, ref)
+    except BuildException as be:
+        msg = "Could not scan app %s due to BuildException: %s" % (app['id'], be)
+        return (None, msg)
+    except VCSException as vcse:
+        msg = "VCS error while scanning app %s: %s" % (app['id'], vcse)
+        return (None, msg)
+    except Exception:
+        msg = "Could not scan app %s due to unknown error: %s" % (app['id'], traceback.format_exc())
+        return (None, msg)
 
 # Check for a new version by looking at the Google Play Store.
 # Returns (None, "a message") if this didn't work, or (version, None) for
@@ -307,6 +336,8 @@ def main():
                 (version, vercode) = check_repomanifest(app, sdk_path)
             elif mode.startswith('RepoManifest/'):
                 (version, vercode) = check_repomanifest(app, sdk_path, mode[13:])
+            elif mode == 'RepoTrunk':
+                (version, vercode) = check_repotrunk(app, sdk_path)
             elif mode == 'HTTP':
                 (version, vercode) = check_http(app)
             elif mode == 'Static':
index b4a164f3a3cdd847a7a85f3fe6731f658b8c9484..b4bac82019d432a6e5d23ccd8e6be71cae55e2db 100644 (file)
@@ -126,6 +126,10 @@ class vcs:
     def gettags(self):
         raise VCSException('gettags not supported for this vcs type')
 
+    # Get current commit reference (hash, revision, etc)
+    def getref(self):
+        raise VCSException('getref not supported for this vcs type')
+
     # Returns the srclib (name, path) used in setting up the current
     # revision, or None.
     def getsrclib(self):
@@ -287,6 +291,12 @@ class vcs_gitsvn(vcs):
         self.checkrepo()
         return os.listdir(os.path.join(self.local, '.git/svn/refs/remotes/tags'))
 
+    def getref(self):
+        self.checkrepo()
+        p = subprocess.Popen(['git', 'svn', 'find-rev', 'HEAD'],
+                stdout=subprocess.PIPE, cwd=self.local)
+        return p.communicate()[0]
+
 class vcs_svn(vcs):
 
     def repotype(self):
@@ -321,6 +331,12 @@ class vcs_svn(vcs):
                 self.userargs(), cwd=self.local) != 0:
             raise VCSException("Svn update failed")
 
+    def getref(self):
+        p = subprocess.Popen(['svn', 'info'],
+                stdout=subprocess.PIPE, cwd=self.local)
+        for line in p.communicate()[0].splitlines():
+            if line is not None and line.startswith('Last Changed Rev: '):
+                return line[18:]
 
 class vcs_hg(vcs):