aboutsummaryrefslogtreecommitdiff
path: root/wrap.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-03-21 14:33:52 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2015-03-21 14:33:52 +0200
commit81754680f03bd49020113da64e563db3b7fe056f (patch)
tree806cb02aba6e5438ac1324bba17127fca04413b9 /wrap.py
parenta5f30e73c626b4c9284a390669322317a07a6f91 (diff)
downloadmeson-81754680f03bd49020113da64e563db3b7fe056f.zip
meson-81754680f03bd49020113da64e563db3b7fe056f.tar.gz
meson-81754680f03bd49020113da64e563db3b7fe056f.tar.bz2
Refactor git updating to a method.
Diffstat (limited to 'wrap.py')
-rw-r--r--wrap.py36
1 files changed, 20 insertions, 16 deletions
diff --git a/wrap.py b/wrap.py
index 5f9c427..64a87db 100644
--- a/wrap.py
+++ b/wrap.py
@@ -63,26 +63,30 @@ class Resolver:
self.download(p, packagename)
self.extract_package(p)
elif p.type == 'git':
- checkoutdir = os.path.join(self.subdir_root, p.get('directory'))
- revno = p.get('revision')
- is_there = os.path.isdir(checkoutdir)
- if is_there:
- if revno.lower() == 'head':
- subprocess.check_call(['git', 'pull'], cwd=checkoutdir)
- else:
- if subprocess.call(['git', 'checkout', revno], cwd=checkoutdir) != 0:
- subprocess.check_call(['git', 'fetch'], cwd=checkoutdir)
- subprocess.check_call(['git', 'checkout', revno],
- cwd=checkoutdir)
+ self.get_git(p)
+ else:
+ raise RuntimeError('Unreachable code.')
+ return p.get('directory')
+
+ def get_git(self, p):
+ checkoutdir = os.path.join(self.subdir_root, p.get('directory'))
+ revno = p.get('revision')
+ is_there = os.path.isdir(checkoutdir)
+ if is_there:
+ if revno.lower() == 'head':
+ subprocess.check_call(['git', 'pull'], cwd=checkoutdir)
else:
- subprocess.check_call(['git', 'clone', p.get('url'), p.get('directory')],
- cwd=self.subdir_root)
- if revno.lower() != 'head':
+ if subprocess.call(['git', 'checkout', revno], cwd=checkoutdir) != 0:
+ subprocess.check_call(['git', 'fetch'], cwd=checkoutdir)
subprocess.check_call(['git', 'checkout', revno],
cwd=checkoutdir)
else:
- raise RuntimeError('Unreachable code.')
- return p.get('directory')
+ subprocess.check_call(['git', 'clone', p.get('url'),
+ p.get('directory')], cwd=self.subdir_root)
+ if revno.lower() != 'head':
+ subprocess.check_call(['git', 'checkout', revno],
+ cwd=checkoutdir)
+
def get_data(self, url):
u = urllib.request.urlopen(url)