chiark / gitweb /
git-svn improvements
authorDaniel Martí <mvdan@mvdan.cc>
Fri, 5 Apr 2013 13:43:12 +0000 (15:43 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Fri, 5 Apr 2013 13:43:12 +0000 (15:43 +0200)
New features:
* Support for Tags, which allow their use on recipes
* Add Tags Update Check Mode support to git-svn
* Add RepoManifest Update Check Mode support to git-svn

fdroidserver/checkupdates.py
fdroidserver/common.py

index 17f38d45cd9b14c2bdcc1aed10f6a352bc1b29f6..75ecac361bdb453f289a8c731b52dd4e24ac7bf5 100644 (file)
@@ -45,12 +45,15 @@ def check_tags(app, sdk_path):
 
         build_dir = 'build/' + app['id']
 
-        if app['Repo Type'] != 'git':
-            return (None, 'Tags update mode only works for git repositories currently')
+        if app['Repo Type'] not in ('git', 'git-svn'):
+            return (None, 'Tags update mode only works for git and git-svn repositories currently')
 
         # 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('origin/master')
+        if app['Repo Type'] == 'git':
+            vcs.gotorevision('origin/master')
+        elif app['Repo Type'] == 'git-svn':
+            vcs.gotorevision('trunk')
 
         if len(app['builds']) == 0:
             return (None, "Can't use Tags with no builds defined")
@@ -100,12 +103,15 @@ def check_repomanifest(app, sdk_path):
 
         build_dir = 'build/' + app['id']
 
-        if app['Repo Type'] != 'git':
-            return (None, 'RepoManifest update mode only works for git repositories currently')
+        if app['Repo Type'] not in ('git', 'git-svn'):
+            return (None, 'RepoManifest update mode only works for git and git-svn repositories currently')
 
         # 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('origin/master')
+        if app['Repo Type'] == 'git':
+            vcs.gotorevision('origin/master')
+        elif app['Repo Type'] == 'git-svn':
+            vcs.gotorevision('trunk')
 
         if len(app['builds']) == 0:
             return (None, "Can't use RepoManifest with no builds defined")
index 9a43045b8d893f09824d8fbe77a9c3959716e0b2..0db812a44f4ea1a946f31f72e474ee597f0160cf 100644 (file)
@@ -197,7 +197,7 @@ class vcs_gitsvn(vcs):
     def gotorevisionx(self, rev):
         if not os.path.exists(self.local):
             # Brand new checkout...
-            if subprocess.call(['git', 'svn', 'clone', self.remote, self.local]) != 0:
+            if subprocess.call(['git', 'svn', 'clone', '-T', 'trunk', '-t', 'tags', self.remote, self.local]) != 0:
                 raise VCSException("Git clone failed")
             self.checkrepo()
         else:
@@ -216,19 +216,30 @@ class vcs_gitsvn(vcs):
                     raise VCSException("Git svn rebase failed")
                 self.refreshed = True
         if rev:
-            # Figure out the git commit id corresponding to the svn revision...
-            p = subprocess.Popen(['git', 'svn', 'find-rev', 'r' + rev],
-                cwd=self.local, stdout=subprocess.PIPE)
-            rev = p.communicate()[0].rstrip()
-            if p.returncode != 0 or len(rev) == 0:
-                raise VCSException("Failed to get git treeish from svn rev")
-            # Check out the appropriate revision...
-            if subprocess.call(['git', 'checkout', rev], cwd=self.local) != 0:
-                raise VCSException("Git checkout failed")
+            if rev == 'trunk':
+                if subprocess.call(['git', 'checkout', 'trunk'], cwd=self.local) != 0:
+                    raise VCSException("Git checkout failed")
+            else:
+                # Try finding a svn tag
+                if subprocess.call(['git', 'checkout', 'tags/' + rev], cwd=self.local) != 0:
+                    # No tag found, normal svn rev translation
+                    # Translate svn rev into git format
+                    p = subprocess.Popen(['git', 'svn', 'find-rev', 'r' + rev],
+                        cwd=self.local, stdout=subprocess.PIPE)
+                    rev = p.communicate()[0].rstrip()
+                    if p.returncode != 0 or len(rev) == 0:
+                        raise VCSException("Failed to get git treeish from svn rev")
+                    # Check out the appropriate git revision...
+                    if subprocess.call(['git', 'checkout', rev], cwd=self.local) != 0:
+                        raise VCSException("Git checkout failed")
         # Get rid of any uncontrolled files left behind...
         if subprocess.call(['git', 'clean', '-dffx'], cwd=self.local) != 0:
             raise VCSException("Git clean failed")
 
+    def gettags(self):
+        self.checkrepo()
+        return os.listdir(self.local+'/.git/svn/refs/remotes/tags')
+
 class vcs_svn(vcs):
 
     def repotype(self):