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

Unified Diff: presubmit_support.py

Issue 242140: Git support in presubmit tests.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 11 years, 2 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 | « gclient_scm.py ('k') | 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
===================================================================
--- presubmit_support.py (revision 27963)
+++ presubmit_support.py (working copy)
@@ -389,7 +389,7 @@
def AbsoluteLocalPath(self):
"""Returns the absolute path of this file on the local disk.
"""
- return normpath(os.path.join(self._local_root, self.LocalPath()))
+ return os.path.abspath(os.path.join(self._local_root, self.LocalPath()))
def IsDirectory(self):
"""Returns true if this object is a directory."""
@@ -562,7 +562,8 @@
files = []
self._name = name
self._full_description = description
- self._local_root = local_root
+ # Convert root into an absolute path.
+ self._local_root = os.path.abspath(local_root)
self.issue = issue
self.patchset = patchset
self.scm = ''
@@ -764,6 +765,12 @@
Return:
A list of result objects, empty if no problems.
"""
+
+ # Change to the presubmit file's directory to support local imports.
+ main_path = os.getcwd()
+ os.chdir(os.path.dirname(presubmit_path))
+
+ # Load the presubmit script into context.
input_api = InputApi(self.change, presubmit_path, self.committing)
context = {}
exec script_text in context
@@ -789,6 +796,8 @@
else:
result = () # no error since the script doesn't care about current event.
+ # Return the process to the original working directory.
+ os.chdir(main_path)
return result
@@ -939,7 +948,7 @@
options.files = ParseFiles(args, options.recursive)
else:
# Grab modified files.
- raise NotImplementedException() # TODO(maruel) Implement.
+ options.files = gclient_scm.CaptureGitStatus([options.root])
elif os.path.isdir(os.path.join(options.root, '.svn')):
change_class = SvnChange
if not options.files:
@@ -947,12 +956,15 @@
options.files = ParseFiles(args, options.recursive)
else:
# Grab modified files.
- files = gclient_scm.CaptureSVNStatus([options.root])
+ options.files = gclient_scm.CaptureSVNStatus([options.root])
else:
# Doesn't seem under source control.
change_class = Change
if options.verbose:
- print "Found %d files." % len(options.files)
+ if len(options.files) != 1:
+ print "Found %d files." % len(options.files)
+ else:
+ print "Found 1 file."
return not DoPresubmitChecks(change_class(options.name,
options.description,
options.root,
« no previous file with comments | « gclient_scm.py ('k') | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698