Commit c1675e27 authored by maruel@chromium.org's avatar maruel@chromium.org

Add an optional flag to gcl.ReadFile() so that presubmit can support CRLF PRESUBMIT.py scripts.

Also add a version number to gcl.py.
Review URL: http://codereview.chromium.org/99072

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@14644 0039d316-1c4b-4281-b951-d872f2087c98
parent 02e9e068
......@@ -17,6 +17,10 @@ import tempfile
import upload
import urllib2
__version__ = '1.0'
CODEREVIEW_SETTINGS = {
# Default values.
"CODE_REVIEW_SERVER": "codereview.chromium.org",
......@@ -199,9 +203,9 @@ def RunShell(command, print_output=False):
return RunShellWithReturnCode(command, print_output)[0]
def ReadFile(filename):
def ReadFile(filename, flags='r'):
"""Returns the contents of a file."""
file = open(filename, 'r')
file = open(filename, flags)
result = file.read()
file.close()
return result
......@@ -572,6 +576,7 @@ def Help(argv=None):
print (
"""GCL is a wrapper for Subversion that simplifies working with groups of files.
version """ + __version__ + """
Basic commands:
-----------------------------------------
......
......@@ -6,7 +6,7 @@
"""Enables directory-specific presubmit checks to run at upload and/or commit.
"""
__version__ = '1.0'
__version__ = '1.0.1'
# TODO(joi) Add caching where appropriate/needed. The API is designed to allow
# caching (between all different invocations of presubmit scripts for a given
......@@ -629,7 +629,8 @@ def DoPresubmitChecks(change_info,
for filename in presubmit_files:
if verbose:
print "Running %s" % filename
presubmit_script = gcl.ReadFile(filename)
# Accept CRLF presubmit script.
presubmit_script = gcl.ReadFile(filename, 'Ur')
results += executer.ExecPresubmitScript(presubmit_script, filename)
errors = []
......
......@@ -53,7 +53,7 @@ class PresubmitTestsBase(unittest.TestCase):
gcl.GetSVNFileProperty = MockGetSVNFileProperty
self.original_ReadFile = gcl.ReadFile
def MockReadFile(path):
def MockReadFile(path, dummy='r'):
if path.count('nosuchfile'):
return None
elif path.endswith('isdir'):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment