[library-web] reuse old git generated tarballs if possible



commit 73a01e31051d09bb6c34b88a49bdf07c8586898f
Author: Frédéric Péters <fpeters 0d be>
Date:   Tue Jan 28 18:10:58 2014 +0000

    reuse old git generated tarballs if possible

 src/lgo.py |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/src/lgo.py b/src/lgo.py
index 3e2ba68..1391d75 100755
--- a/src/lgo.py
+++ b/src/lgo.py
@@ -303,6 +303,13 @@ class Lgo(App):
                 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()
+
+            old_hash = None
+            hash_filename = os.path.join(module_git_clone_dir, '.lgo.head')
+            if os.path.exists(hash_filename):
+                old_hash = file(hash_filename).read().strip()
+                os.unlink(hash_filename)
+
             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()
@@ -320,10 +327,24 @@ class Lgo(App):
                 else:
                     logging.debug('branch do not exist, skipping')
                     return
+
+            subp = subprocess.Popen(['git', 'rev-parse', 'HEAD'],
+                    stdout=subprocess.PIPE, cwd=module_git_clone_dir)
+            stdout, stderr = subp.communicate()
+            new_hash = stdout.strip()
+
+            file(hash_filename, 'w').write(new_hash)
+
             filename = '%s-%s.tar.gz' % (module_name, fake_version_number)
-            subprocess.Popen(['tar', 'czhf', filename, module_name + '/',
-                    '--exclude=.git'], cwd=base_git_dir).wait()
-            return os.path.join(base_git_dir, filename)
+            filepath = os.path.join(base_git_dir, filename)
+
+            if new_hash != old_hash and os.path.exists(filepath):
+                os.unlink(filepath)
+
+            if not os.path.exists(filepath):
+                subprocess.Popen(['tar', 'czhf', filename, module_name + '/',
+                        '--exclude=.git'], cwd=base_git_dir).wait()
+            return filepath
         elif url.startswith('gnome://'):
             # special schema for modules on ftp.gnome.org; URL scheme is
             # gnome://<modulename>?min=<minimum version>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]