1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-09-17 10:40:12 +02:00

git-svn improvements

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
This commit is contained in:
Daniel Martí 2013-04-05 15:43:12 +02:00
parent fdc04fe64e
commit 3abfa5714c
2 changed files with 33 additions and 16 deletions

View 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")

View 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):