1 # Script for checking which projects have unsubmitted modifications in them. 2 # 3 # Usage: 4 # - recommended to add a alias/bat/sh for a shorter command 5 # - running without parameters will check any existing known dE projects. 6 # - can give projects names on command line, if only wish to check a sub-set 7 # e.g., git-check.py delibs deqp 8 9 import os 10 import sys 11 12 COMMANDS = ["pull", "push", "check"] 13 ALL_REPOS = ["delibs", "deqp", "movies", "domeni", "demisc"] 14 15 # Defaults. 16 command = "check" 17 repos = ALL_REPOS 18 19 # Parse command line. 20 numArgs = len(sys.argv) 21 if (numArgs == 1): 22 pass 23 else: 24 if (sys.argv[1] in COMMANDS): 25 command = sys.argv[1] 26 if (numArgs > 2): 27 repos = sys.argv[2:] 28 else: 29 repos = sys.argv[1:] 30 31 def findRepo(x): 32 for repo in ALL_REPOS: 33 if repo.startswith(x): 34 return repo 35 print "%s not a valid repository directory" % x 36 sys.exit(1) 37 38 repoDirs = [findRepo(x) for x in repos] 39 40 # Find git base repo directory. 41 oldDir = os.getcwd() 42 baseDir = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../..")) 43 foundAny = False 44 45 # Execute the command. 46 print "## Executing '%s' on repos: %s" % (command.upper(), ", ".join(repoDirs)) 47 print "" 48 49 for gitDir in repoDirs: 50 subDir = os.path.join(baseDir, gitDir) 51 if os.path.exists(subDir): 52 foundAny = True 53 print "***** Check directory '%s' *****" % subDir 54 os.chdir(subDir) 55 if command == "check": 56 os.system("git status") 57 os.system("git push --dry-run") 58 elif command == "push": 59 os.system("git push") 60 elif command == "pull": 61 os.system("git pull") 62 else: 63 assert False 64 print "" 65 66 if not foundAny: 67 print "No subdirs found -- tried %s" % repoDirs 68 print "Searching in '%s'" % baseDir 69 70 os.chdir(oldDir) 71