7 SCRIPTDIR = os.path.dirname(__file__)
33 cls.HEADER = '\033[95m'
34 cls.OKBLUE = '\033[94m'
35 cls.OKGREEN = '\033[92m'
36 cls.WARNING = '\033[93m'
42 def git(args, repository_path):
43 if not isinstance(args, list):
46 return subprocess.check_output(["git"] + args, cwd=repository_path).decode()
49 def update_subprojects():
50 subprojects_dir = os.path.join(SCRIPTDIR, "subprojects")
51 for repo_name in os.listdir(subprojects_dir):
52 repo_dir = os.path.normpath(os.path.join(SCRIPTDIR, subprojects_dir, repo_name))
53 if not os.path.exists(os.path.join(repo_dir, '.git')):
56 print("Updating %s..." % repo_name)
58 git(["pull", "--rebase"], repo_dir)
59 except Exception as e:
60 print("\nCould not rebase %s, please fix and try again\nerror:\n %s" % (repo_dir, e))
63 commit_message = git("show", repo_dir).split("\n")
64 print(u" -> %s%s%s — %s" % (Colors.HEADER, commit_message[0][7:14], Colors.ENDC,
65 commit_message[4].strip()))
70 if __name__ == "__main__":
71 parser = argparse.ArgumentParser(prog="git-update")
73 parser.add_argument("--no-color",
76 help="Do not output ansi colors.")
77 options = parser.parse_args()
81 exit(not update_subprojects())