diff options
author | Liz Kammer <eakammer@google.com> | 2020-07-01 15:22:21 -0700 |
---|---|---|
committer | Liz Kammer <eakammer@google.com> | 2020-10-20 15:01:41 +0000 |
commit | 239625cee5e913e15ea070862a7921759d27dca6 (patch) | |
tree | 7123ba7d87643f6c167df22c25addd069810627f | |
parent | 573d316aa2a01cb56c8c707f7fc655e6ecc1db2a (diff) | |
download | repohooks-239625cee5e913e15ea070862a7921759d27dca6.tar.gz |
Add support for automatic fixups to gofmt.androidx-print-release
gofmt -w writes the gofmt result to the source file for the files that
gofmt reports issues.
Bug: 116112526
Test: ran hook for gofmt can now auto-fix formatting
Change-Id: Ic676a588a567fbe5cf3f7a1411ac8048bde2af06
-rw-r--r-- | rh/hooks.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/rh/hooks.py b/rh/hooks.py index 491da91..dd4cab3 100644 --- a/rh/hooks.py +++ b/rh/hooks.py @@ -771,9 +771,10 @@ def check_gofmt(project, commit, _desc, diff, options=None): data = rh.git.get_file_content(commit, d.file) result = _run(cmd, input=data) if result.stdout: + fixup_func = _fixup_func_caller([gofmt, '-w', d.file]) ret.append(rh.results.HookResult( 'gofmt', project, commit, error=result.stdout, - files=(d.file,))) + files=(d.file,), fixup_func=fixup_func)) return ret |