Minor improvement in the git function
authorThibault Saunier <thibault.saunier@osg.samsung.com>
Tue, 11 Oct 2016 00:05:39 +0000 (02:05 +0200)
committerThibault Saunier <thibault.saunier@osg.samsung.com>
Tue, 11 Oct 2016 00:05:39 +0000 (02:05 +0200)
common.py
configure
git-update

index 65d5b2d..244b30a 100644 (file)
--- a/common.py
+++ b/common.py
@@ -34,11 +34,6 @@ class Colors:
 
 
 
-def git(args, repository_path):
-    if not isinstance(args, list):
-        args = [args]
-
-    return subprocess.check_output(["git"] + args, cwd=repository_path,
+def git(*args, repository_path='.'):
+    return subprocess.check_output(["git"] + list(args), cwd=repository_path,
                                    stderr=subprocess.STDOUT).decode()
-
-
index 9d9a7e1..2b6d867 100755 (executable)
--- a/configure
+++ b/configure
@@ -17,9 +17,9 @@ ROOTDIR = os.path.abspath(os.path.dirname(__file__))
 
 
 def get_meson():
-    print("Updating meson submodule...", end='')
+    print("Updating meson submodule... ", end='')
     sys.stdout.flush()
-    git(['submodule', 'update', '--init'], ROOTDIR)
+    git('submodule', 'update', '--init', repository_path=ROOTDIR)
     print("DONE")
 
     return os.path.join(ROOTDIR, 'meson', 'meson.py')
index 163574f..ee65a23 100755 (executable)
@@ -43,10 +43,10 @@ def update_repo(repo_name, repo_dir, revision, no_interaction, recurse_i=0):
     print("Updating %s..." % repo_name)
     try:
         if revision:
-            git(["fetch"], repo_dir)
-            git(["checkout", revision], repo_dir)
+            git("fetch", repository_path=repo_dir)
+            git("checkout", revision, repository_path=repo_dir)
         else:
-            git(["pull", "--rebase"], repo_dir)
+            git("pull", "--rebase", repository_path=repo_dir)
     except Exception as e:
         out = getattr(e, "output", b"").decode()
         if not no_interaction:
@@ -73,7 +73,7 @@ def update_repo(repo_name, repo_dir, revision, no_interaction, recurse_i=0):
             return False
 
 
-    commit_message = git("show", repo_dir).split("\n")
+    commit_message = git("show", repository_path=repo_dir).split("\n")
     print(u"  -> %s%s%s — %s" % (Colors.HEADER, commit_message[0][7:14], Colors.ENDC,
                                     commit_message[4].strip()))