Add support for automatic fixups to gofmt.
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
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 @@
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