Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(826)

Unified Diff: presubmit_support.py

Issue 6459010: Improve presubmit_support.py handling of git checkout. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_support.py
diff --git a/presubmit_support.py b/presubmit_support.py
index 79bc306bdcb306be12afca6929d25e0b548e4177..049438d7500eef415ab988178adf54fe3e9ca22d 100755
--- a/presubmit_support.py
+++ b/presubmit_support.py
@@ -1053,6 +1053,7 @@ def ScanSubDirs(mask, recursive):
def ParseFiles(args, recursive):
+ logging.debug('Searching for %s' % args)
files = []
for arg in args:
files.extend([('M', f) for f in ScanSubDirs(arg, recursive)])
@@ -1083,15 +1084,9 @@ def Main(argv):
parser.add_option("--default_presubmit")
parser.add_option("--may_prompt", action='store_true', default=False)
options, args = parser.parse_args(argv[1:])
- if os.path.isdir(os.path.join(options.root, '.git')):
- change_class = GitChange
- if not options.files:
- if args:
- options.files = ParseFiles(args, options.recursive)
- else:
- # Grab modified files.
- options.files = scm.GIT.CaptureStatus([options.root])
- elif os.path.isdir(os.path.join(options.root, '.svn')):
+ if options.verbose:
+ logging.basicConfig(level=logging.DEBUG)
+ if os.path.isdir(os.path.join(options.root, '.svn')):
change_class = SvnChange
if not options.files:
if args:
@@ -1100,10 +1095,27 @@ def Main(argv):
# Grab modified files.
options.files = scm.SVN.CaptureStatus([options.root])
else:
- # Doesn't seem under source control.
- change_class = Change
+ is_git = os.path.isdir(os.path.join(options.root, '.git'))
+ if not is_git:
+ is_git = (0 == subprocess.call(
+ ['git', 'rev-parse', '--show-cdup'],
+ stdout=subprocess.PIPE, cwd=options.root))
+ if is_git:
+ # Only look at the subdirectories below cwd.
+ change_class = GitChange
+ if not options.files:
+ if args:
+ options.files = ParseFiles(args, options.recursive)
+ else:
+ # Grab modified files.
+ options.files = scm.GIT.CaptureStatus([options.root])
+ else:
+ logging.info('Doesn\'t seem under source control.')
+ change_class = Change
if options.verbose:
- if len(options.files) != 1:
+ if not options.files:
+ print "Found no files."
+ elif len(options.files) != 1:
print "Found %d files." % len(options.files)
else:
print "Found 1 file."
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698