Commit e5299012 authored by thomasvl@chromium.org's avatar thomasvl@chromium.org

Allow the existence of ~/.gcl_upload_no_try override the default of try on upload.

Review URL: http://codereview.chromium.org/1619005

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@43854 0039d316-1c4b-4281-b951-d872f2087c98
parent 8cf7a391
......@@ -58,6 +58,20 @@ MISSING_TEST_MSG = "Change contains new or modified methods, but no new tests!"
# Global cache of files cached in GetCacheDir().
FILES_CACHE = {}
def CheckHomeForFile(filename):
"""Checks the users home dir for the existence of the given file. Returns
the path to the file if it's there, or None if it is not.
"""
home_vars = ['HOME']
if sys.platform in ('cygwin', 'win32'):
home_vars.append('USERPROFILE')
for home_var in home_vars:
home = os.getenv(home_var)
if home != None:
full_path = os.path.join(home, filename)
if os.path.exists(full_path):
return full_path
return None
def UnknownFiles(extra_args):
"""Runs svn status and returns unknown files.
......@@ -624,6 +638,8 @@ Basic commands:
[--send_mail] [--no_try] [--no_presubmit]
[--no_watchlists]
Uploads the changelist to the server for review.
(You can create the file '.gcl_upload_no_try' in your home dir to
skip the automatic tries.)
gcl commit change_name [--no_presubmit]
Commits the changelist to the repository.
......@@ -706,7 +722,12 @@ def UploadCL(change_info, args):
return
if not OptionallyDoPresubmitChecks(change_info, False, args):
return
no_try = FilterFlag(args, "--no_try") or FilterFlag(args, "--no-try")
# Might want to support GetInfoDir()/GetRepositoryRoot() like
# CheckHomeForFile() so the skip of tries can be per tree basis instead
# of user global.
no_try = FilterFlag(args, "--no_try") or \
FilterFlag(args, "--no-try") or \
not (CheckHomeForFile(".gcl_upload_no_try") is None)
no_watchlists = FilterFlag(args, "--no_watchlists") or \
FilterFlag(args, "--no-watchlists")
......
......@@ -33,13 +33,13 @@ class GclUnittest(GclTestsBase):
members = [
'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE', 'Change',
'ChangeInfo', 'Changes', 'Commit', 'DEFAULT_LINT_IGNORE_REGEX',
'DEFAULT_LINT_REGEX', 'DeleteEmptyChangeLists', 'DoPresubmitChecks',
'ErrorExit', 'FILES_CACHE', 'FilterFlag', 'GenerateChangeName',
'GenerateDiff', 'GetCLs', 'GetCacheDir', 'GetCachedFile',
'GetChangelistInfoFile', 'GetChangesDir', 'GetCodeReviewSetting',
'GetEditor', 'GetFilesNotInCL', 'GetInfoDir', 'GetIssueDescription',
'GetModifiedFiles', 'GetRepositoryRoot', 'Help', 'Lint',
'LoadChangelistInfoForMultiple', 'MISSING_TEST_MSG', 'Opened',
'DEFAULT_LINT_REGEX', 'CheckHomeForFile', 'DeleteEmptyChangeLists',
'DoPresubmitChecks', 'ErrorExit', 'FILES_CACHE', 'FilterFlag',
'GenerateChangeName', 'GenerateDiff', 'GetCLs', 'GetCacheDir',
'GetCachedFile', 'GetChangelistInfoFile', 'GetChangesDir',
'GetCodeReviewSetting', 'GetEditor', 'GetFilesNotInCL', 'GetInfoDir',
'GetIssueDescription', 'GetModifiedFiles', 'GetRepositoryRoot', 'Help',
'Lint', 'LoadChangelistInfoForMultiple', 'MISSING_TEST_MSG', 'Opened',
'OptionallyDoPresubmitChecks', 'PresubmitCL', 'REPOSITORY_ROOT',
'RunShell', 'RunShellWithReturnCode', 'SVN',
'SendToRietveld', 'TryChange', 'UnknownFiles', 'UploadCL', 'Warn',
......@@ -62,6 +62,10 @@ class GclUnittest(GclTestsBase):
# TODO(maruel): TEST ME
pass
def testCheckHomeForFile(self):
# TODO(maruel): TEST ME
pass
def testGetRepositoryRootNone(self):
gcl.os.getcwd().AndReturn(self.fake_root_dir)
gcl.SVN.GetCheckoutRoot(self.fake_root_dir).AndReturn(None)
......@@ -229,6 +233,7 @@ class ChangeInfoUnittest(GclTestsBase):
class UploadCLUnittest(GclTestsBase):
def setUp(self):
GclTestsBase.setUp(self)
self.mox.StubOutWithMock(gcl, 'CheckHomeForFile')
self.mox.StubOutWithMock(gcl, 'DoPresubmitChecks')
self.mox.StubOutWithMock(gcl, 'GenerateDiff')
self.mox.StubOutWithMock(gcl, 'GetCodeReviewSetting')
......@@ -246,6 +251,7 @@ class UploadCLUnittest(GclTestsBase):
change_info.patch = None
files = [item[1] for item in change_info.files]
args = ['--foo=bar']
gcl.CheckHomeForFile('.gcl_upload_no_try').AndReturn(None)
gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True)
gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server')
gcl.os.getcwd().AndReturn('somewhere')
......@@ -273,6 +279,7 @@ class UploadCLUnittest(GclTestsBase):
self.mox.StubOutWithMock(change_info, 'Save')
args = ['--server=a', '--no_watchlists']
change_info.Save()
gcl.CheckHomeForFile('.gcl_upload_no_try').AndReturn(None)
gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True)
gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server')
gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile'))
......@@ -327,6 +334,7 @@ class UploadCLUnittest(GclTestsBase):
self.mox.StubOutWithMock(change_info, 'Save')
args = ['--no_watchlists']
change_info.Save()
gcl.CheckHomeForFile('.gcl_upload_no_try').AndReturn(None)
gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True)
gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server')
gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile'))
......
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