chiark / gitweb /
Support UCM:Tags <pattern> using git tag -l <pattern>
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 10 Feb 2014 10:27:28 +0000 (11:27 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 10 Feb 2014 10:29:12 +0000 (11:29 +0100)
fdroidserver/checkupdates.py
fdroidserver/common.py
fdroidserver/metadata.py

index 4984ef2203dc23b9110d40e22464abc2703df8b3..46fe7f7effaedaca5140e1fa20a95da6dad527c9 100644 (file)
@@ -85,7 +85,7 @@ def check_http(app):
 # caution, because it's inappropriate for many projects.
 # Returns (None, "a message") if this didn't work, or (version, vercode) for
 # the details of the current version.
-def check_tags(app):
+def check_tags(app, pattern):
 
     try:
 
@@ -98,6 +98,8 @@ def check_tags(app):
 
         if repotype not in ('git', 'git-svn', 'hg', 'bzr'):
             return (None, 'Tags update mode only works for git, hg, bzr and git-svn repositories currently', None)
+        if pattern and repotype not in ('git'):
+            return (None, 'Tags with pattern update mode only works for git repositories currently', None)
 
         # Set up vcs interface and make sure we have the latest code...
         vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir)
@@ -115,7 +117,9 @@ def check_tags(app):
         hver = None
         hcode = "0"
 
-        for tag in vcs.gettags():
+        tags = vcs.gettags_pattern(pattern) if pattern else vcs.gettags()
+
+        for tag in tags:
             logging.info("Check tag: '{0}'".format(tag))
             vcs.gotorevision(tag)
 
@@ -346,8 +350,9 @@ def main():
         msg = None
         vercode = None
         mode = app['Update Check Mode']
-        if mode == 'Tags':
-            (version, vercode, tag) = check_tags(app)
+        if mode.startswith('Tags'):
+            pattern = mode[5:] if len(mode) > 4 else None
+            (version, vercode, tag) = check_tags(app, pattern)
         elif mode == 'RepoManifest':
             (version, vercode) = check_repomanifest(app)
         elif mode.startswith('RepoManifest/'):
index d9721d8c0f622075fa9688a8dc700eee3fcd8855..4509338bb663f96df08ab4b3d9af5e0c6e4c810e 100644 (file)
@@ -275,6 +275,10 @@ class vcs:
     def gettags(self):
         raise VCSException('gettags not supported for this vcs type')
 
+    # Get a list of all known tags
+    def gettags_pattern(self, pattern):
+        raise VCSException('gettags with pattern 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')
@@ -352,6 +356,11 @@ class vcs_git(vcs):
         p = FDroidPopen(['git', 'tag'], cwd=self.local)
         return p.stdout.splitlines()
 
+    def gettags_pattern(self, pattern):
+        self.checkrepo()
+        p = FDroidPopen(['git', 'tag', '-l', pattern], cwd=self.local)
+        return p.stdout.splitlines()
+
 
 class vcs_gitsvn(vcs):
 
index 267095cc8db0bca47eb3baeecbf9dd560e97298b..8103e347c24254a6e10bee074814dbca02184163 100644 (file)
@@ -175,7 +175,7 @@ valuetypes = {
         [ ]),
 
     'updatecheckmodes' : FieldType("Update Check Mode",
-        r"^(Tags|RepoManifest|RepoManifest/.+|RepoTrunk|HTTP|Static|None)$", None,
+        r"^(Tags|Tags .+|RepoManifest|RepoManifest/.+|RepoTrunk|HTTP|Static|None)$", None,
         [ "Update Check Mode" ],
         [ ])
 }