From 6a1d489cc57306b8d45559f4c2d9b3595b39af56 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 11 Oct 2016 02:05:39 +0200 Subject: [PATCH] Minor improvement in the git function --- common.py | 9 ++------- configure | 4 ++-- git-update | 8 ++++---- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/common.py b/common.py index 65d5b2d..244b30a 100644 --- 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() - - diff --git a/configure b/configure index 9d9a7e1..2b6d867 100755 --- 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') diff --git a/git-update b/git-update index 163574f..ee65a23 100755 --- a/git-update +++ b/git-update @@ -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())) -- 2.7.4