diff --git a/git_cl.py b/git_cl.py index 72bc1923e..b2eef8845 100755 --- a/git_cl.py +++ b/git_cl.py @@ -830,6 +830,7 @@ class Settings(object): self.squash_gerrit_uploads = None self.gerrit_skip_ensure_authenticated = None self.git_editor = None + self.format_full_by_default = None def LazyUpdateIfNeeded(self): """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 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): self.LazyUpdateIfNeeded() 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('run-post-upload-hook', 'RUN_POST_UPLOAD_HOOK', unset_error_ok=True) + SetProperty( + 'format-full-by-default', 'FORMAT_FULL_BY_DEFAULT', unset_error_ok=True) if 'GERRIT_HOST' in keyvals: RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']]) @@ -5162,7 +5173,7 @@ def CMDformat(parser, args): except clang_format.NotFoundError as e: DieWithError(e) - if opts.full: + if opts.full or settings.GetFormatFullByDefault(): cmd = [clang_format_tool] if not opts.dry_run and not opts.diff: cmd.append('-i') diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index f6e5d6fef..e1b2266dd 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -724,6 +724,8 @@ class TestGitCl(TestCase): CERR1), ((['git', 'config', '--unset-all', 'rietveld.run-post-upload-hook'],), CERR1), + ((['git', 'config', '--unset-all', 'rietveld.format-full-by-default'],), + CERR1), ((['git', 'config', 'gerrit.host', 'true'],), ''), ] self.assertIsNone(git_cl.LoadCodereviewSettingsFromFile(codereview_file))