@ -830,6 +830,7 @@ class Settings(object):
self . squash_gerrit_uploads = None
self . squash_gerrit_uploads = None
self . gerrit_skip_ensure_authenticated = None
self . gerrit_skip_ensure_authenticated = None
self . git_editor = None
self . git_editor = None
self . format_full_by_default = None
def LazyUpdateIfNeeded ( self ) :
def LazyUpdateIfNeeded ( self ) :
""" Updates the settings from a codereview.settings file, if available. """
""" Updates the settings from a codereview.settings file, if available. """
@ -938,6 +939,14 @@ class Settings(object):
return ( self . _GetConfig ( ' rietveld.cpplint-ignore-regex ' , error_ok = True ) or
return ( self . _GetConfig ( ' rietveld.cpplint-ignore-regex ' , error_ok = True ) or
DEFAULT_LINT_IGNORE_REGEX )
DEFAULT_LINT_IGNORE_REGEX )
def GetFormatFullByDefault ( self ) :
if self . format_full_by_default is None :
result = (
RunGit ( [ ' config ' , ' --bool ' , ' rietveld.format-full-by-default ' ] ,
error_ok = True ) . strip ( ) )
self . format_full_by_default = ( result == ' true ' )
return self . format_full_by_default
def _GetConfig ( self , param , * * kwargs ) :
def _GetConfig ( self , param , * * kwargs ) :
self . LazyUpdateIfNeeded ( )
self . LazyUpdateIfNeeded ( )
return RunGit ( [ ' config ' , param ] , * * kwargs ) . strip ( )
return RunGit ( [ ' config ' , param ] , * * kwargs ) . strip ( )
@ -3149,6 +3158,8 @@ def LoadCodereviewSettingsFromFile(fileobj):
SetProperty ( ' cpplint-ignore-regex ' , ' LINT_IGNORE_REGEX ' , unset_error_ok = True )
SetProperty ( ' cpplint-ignore-regex ' , ' LINT_IGNORE_REGEX ' , unset_error_ok = True )
SetProperty ( ' run-post-upload-hook ' , ' RUN_POST_UPLOAD_HOOK ' ,
SetProperty ( ' run-post-upload-hook ' , ' RUN_POST_UPLOAD_HOOK ' ,
unset_error_ok = True )
unset_error_ok = True )
SetProperty (
' format-full-by-default ' , ' FORMAT_FULL_BY_DEFAULT ' , unset_error_ok = True )
if ' GERRIT_HOST ' in keyvals :
if ' GERRIT_HOST ' in keyvals :
RunGit ( [ ' config ' , ' gerrit.host ' , keyvals [ ' GERRIT_HOST ' ] ] )
RunGit ( [ ' config ' , ' gerrit.host ' , keyvals [ ' GERRIT_HOST ' ] ] )
@ -5162,7 +5173,7 @@ def CMDformat(parser, args):
except clang_format . NotFoundError as e :
except clang_format . NotFoundError as e :
DieWithError ( e )
DieWithError ( e )
if opts . full :
if opts . full or settings . GetFormatFullByDefault ( ) :
cmd = [ clang_format_tool ]
cmd = [ clang_format_tool ]
if not opts . dry_run and not opts . diff :
if not opts . dry_run and not opts . diff :
cmd . append ( ' -i ' )
cmd . append ( ' -i ' )