[library-web] make it possible to update a stable module from git
- From: Frederic Peters <fpeters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [library-web] make it possible to update a stable module from git
- Date: Tue, 28 Jan 2014 12:17:53 +0000 (UTC)
commit b521aba8d8836c4758743804808c4e92cf469d62
Author: Frédéric Péters <fpeters 0d be>
Date: Tue Jan 28 11:57:40 2014 +0000
make it possible to update a stable module from git
src/lgo.py | 38 ++++++++++++++++++++++++++++++++++++--
src/modtypes/base.py | 2 ++
2 files changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/src/lgo.py b/src/lgo.py
index 6a7dcf2..e66c20a 100755
--- a/src/lgo.py
+++ b/src/lgo.py
@@ -22,6 +22,7 @@ import os
import sys
import re
import tempfile
+import cgi
import urllib2
import urlparse
from cStringIO import StringIO
@@ -268,9 +269,42 @@ class Lgo(App):
moduleset.seek(0)
self.process_latest_moduleset(moduleset)
-
def download(self, url, use_cache=True):
- if url.startswith('gnome://'):
+ if url.startswith('gnome+git://'):
+ parsed_url = urlparse.urlparse(url)
+ module_name = parsed_url.netloc
+ branch_name = cgi.parse_qs(parsed_url.query).get('branch')[0]
+ version_value = cgi.parse_qs(parsed_url.query).get('version')[0]
+
+ if not version_value.startswith('.'.join(branch_name.split('-')[1:])):
+ logging.debug('ignoring git for %s (version != branch)' % module_name)
+ return
+
+ fake_version_number = version_value
+
+ base_git_dir = os.path.join(self.config.download_cache_dir, 'git')
+ if not os.path.exists(base_git_dir):
+ os.mkdir(base_git_dir)
+ module_git_clone_dir = os.path.join(base_git_dir, module_name)
+ if os.path.exists(module_git_clone_dir):
+ logging.debug('running git pull in %s' % module_git_clone_dir)
+ subprocess.Popen(['git', 'pull'], cwd=module_git_clone_dir).wait()
+ else:
+ logging.debug('running git clone of %s' % module_name)
+ subprocess.Popen(['git', 'clone', 'git://git.gnome.org/%s' % module_name],
+ cwd=base_git_dir).wait()
+ logging.debug('switching to branch %s' % branch_name)
+ subprocess.Popen(['git', 'checkout', '-b', branch_name, 'origin/%s' % branch_name],
+ cwd=module_git_clone_dir).wait()
+ if subprocess.call(['git', 'show-ref', '--verify', '--quiet',
+ 'refs/heads/%s' % branch_name]) != 0:
+ logging.debug('branch do not exist, skipping')
+ return
+ filename = '%s-%s.tar.gz' % (module_name, fake_version_number)
+ subprocess.Popen(['tar', 'czf', filename, module_name],
+ cwd=base_git_dir).wait()
+ return os.path.join(base_git_dir, filename)
+ elif url.startswith('gnome://'):
# special schema for modules on ftp.gnome.org; URL scheme is
# gnome://<modulename>?min=<minimum version>
# (the parameters are optional)
diff --git a/src/modtypes/base.py b/src/modtypes/base.py
index f805100..411602a 100644
--- a/src/modtypes/base.py
+++ b/src/modtypes/base.py
@@ -70,6 +70,8 @@ class DocModule(object):
self.version = os.path.splitext(tar.name)[0].split('-')[-1]
if self.version.endswith('.tar'):
self.version = self.version[:-4]
+ if self.version.endswith('.999'):
+ self.version = self.version[:-4]
if nightly or self.version == 'nightly':
self.nightly = True
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]