• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
9import os
10import sys
11
12COMMANDS	= ["pull", "push", "check"]
13ALL_REPOS	= ["delibs", "deqp", "movies", "domeni", "demisc"]
14
15# Defaults.
16command = "check"
17repos	= ALL_REPOS
18
19# Parse command line.
20numArgs = len(sys.argv)
21if (numArgs == 1):
22	pass
23else:
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
31def 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
38repoDirs = [findRepo(x) for x in repos]
39
40# Find git base repo directory.
41oldDir		= os.getcwd()
42baseDir 	= os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../.."))
43foundAny	= False
44
45# Execute the command.
46print "## Executing '%s' on repos: %s" % (command.upper(), ", ".join(repoDirs))
47print ""
48
49for 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
66if not foundAny:
67	print "No subdirs found -- tried %s" % repoDirs
68	print "Searching in '%s'" % baseDir
69
70os.chdir(oldDir)
71