chiark / gitweb /
Merge branch 'py3' into 'master'
authorDaniel Martí <mvdan@mvdan.cc>
Fri, 11 Mar 2016 23:51:56 +0000 (23:51 +0000)
committerDaniel Martí <mvdan@mvdan.cc>
Fri, 11 Mar 2016 23:51:56 +0000 (23:51 +0000)
Python 3

I tried to keep commits separate, so if anything causes trouble, it can be reverted or changed easily.

* pre-commit hooks pass
* all tests pass
* My use of `build`, `checkupdates`, `lint`, `import`, `publish` and `update` work as usual
* 2to3 does not report anything useful anymore (only useless parentheses and list() encapsulation of iterators)
* rewritemeta works exactly as usual

CC @eighthave

See merge request !88

fdroidserver/checkupdates.py
fdroidserver/common.py

index 46200199f4b2bb97aa1ee0fe360ebf34c2ec2a45..d9514cd93817d22863f0fd9f13c48679ee171356 100644 (file)
@@ -121,7 +121,11 @@ def check_tags(app, pattern):
         hver = None
         hcode = "0"
 
-        tags = vcs.gettags()
+        tags = []
+        if repotype == 'git':
+            tags = vcs.latesttags()
+        else:
+            tags = vcs.gettags()
         if not tags:
             return (None, "No tags found", None)
 
@@ -133,8 +137,8 @@ def check_tags(app, pattern):
                 return (None, "No matching tags found", None)
             logging.debug("Matching tags: " + ','.join(tags))
 
-        if len(tags) > 5 and repotype in ('git',):
-            tags = vcs.latesttags(tags, 5)
+        if len(tags) > 5 and repotype == 'git':
+            tags = tags[:5]
             logging.debug("Latest tags: " + ','.join(tags))
 
         for tag in tags:
index 6eaab93693461ea70afcea52de995a182a3e90d4..ab6f238ac535b36a4c5cdebc9bd057aceb6d5b84 100644 (file)
@@ -589,14 +589,8 @@ class vcs:
                 rtags.append(tag)
         return rtags
 
-    def latesttags(self, tags, number):
-        """Get the most recent tags in a given list.
-
-        :param tags: a list of tags
-        :param number: the number to return
-        :returns: A list containing the most recent tags in the provided
-                  list, up to the maximum number given.
-        """
+    # Get a list of all the known tags, sorted from newest to oldest
+    def latesttags(self):
         raise VCSException('latesttags not supported for this vcs type')
 
     # Get current commit reference (hash, revision, etc)
@@ -704,21 +698,21 @@ class vcs_git(vcs):
         p = FDroidPopen(['git', 'tag'], cwd=self.local, output=False)
         return p.output.splitlines()
 
-    def latesttags(self, tags, number):
+    tag_format = re.compile(r'.*tag: ([^),]*).*')
+
+    def latesttags(self):
         self.checkrepo()
-        tl = []
-        for tag in tags:
-            p = FDroidPopen(
-                ['git', 'show', '--format=format:%ct', '-s', tag],
-                cwd=self.local, output=False)
-            # Timestamp is on the last line. For a normal tag, it's the only
-            # line, but for annotated tags, the rest of the info precedes it.
-            ts = int(p.output.splitlines()[-1])
-            tl.append((ts, tag))
-        latest = []
-        for _, t in sorted(tl)[-number:]:
-            latest.append(t)
-        return latest
+        p = FDroidPopen(['git', 'log', '--tags',
+                         '--simplify-by-decoration', '--pretty=format:%d'],
+                        cwd=self.local, output=False)
+        tags = []
+        for line in p.output.splitlines():
+            m = self.tag_format.match(line)
+            if not m:
+                continue
+            tag = m.group(1)
+            tags.append(tag)
+        return tags
 
 
 class vcs_gitsvn(vcs):