aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2023-06-11 00:08:13 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-06-11 00:08:13 +0000
commit3e3044f70fd5f798f26f20a91ba47b500e6775dc (patch)
treeb548bea05014c4f408290fe561b30939907ab1c3
parentc80c743875eb57fcf3e5a8bc229b49048ed3cc78 (diff)
parent13285896d0e51447e5d7e20fb21d89d091d911b9 (diff)
downloadrepohooks-3e3044f70fd5f798f26f20a91ba47b500e6775dc.tar.gz
hooks: ktfmt: drop custom format suggestion am: 13285896d0
Original change: https://android-review.googlesource.com/c/platform/tools/repohooks/+/2621053 Change-Id: Icba5c60d20d61378123fce930eb0ad1e0c395b7d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--rh/hooks.py11
-rwxr-xr-xrh/hooks_unittest.py6
2 files changed, 5 insertions, 12 deletions
diff --git a/rh/hooks.py b/rh/hooks.py
index 1d7eb3f..c90c0a3 100644
--- a/rh/hooks.py
+++ b/rh/hooks.py
@@ -425,15 +425,10 @@ def check_ktfmt(project, commit, _desc, diff, options=None):
('${PREUPLOAD_FILES}',), filtered)
result = _run(cmd)
if result.stdout:
- paths = [os.path.join(project.dir, x.file) for x in filtered]
fixup_cmd = [ktfmt] + args
- error = (
- '\nKotlin files need formatting.\n' +
- 'To reformat the kotlin files in this commit:\n' +
- rh.shell.cmd_to_str(fixup_cmd + paths)
- )
- return [rh.results.HookResult('ktfmt', project, commit, error=error,
- files=paths, fixup_cmd=fixup_cmd)]
+ return [rh.results.HookResult(
+ 'ktfmt', project, commit, error='Formatting errors detected',
+ files=[x.file for x in filtered], fixup_cmd=fixup_cmd)]
return None
diff --git a/rh/hooks_unittest.py b/rh/hooks_unittest.py
index 901eca1..003057e 100755
--- a/rh/hooks_unittest.py
+++ b/rh/hooks_unittest.py
@@ -829,16 +829,14 @@ class BuiltinHooksTests(unittest.TestCase):
rh.git.RawDiffEntry(file='baz/blah.kt')]
ret = rh.hooks.check_ktfmt(
self.project, 'commit', 'desc', diff, options=self.options)
- self.assertListEqual(ret[0].files, ['/.../repo/dir/foo.kt',
- '/.../repo/dir/baz/blah.kt'])
+ self.assertListEqual(ret[0].files, ['foo.kt', 'baz/blah.kt'])
diff = [rh.git.RawDiffEntry(file='foo/f1.kt'),
rh.git.RawDiffEntry(file='bar/f2.kt'),
rh.git.RawDiffEntry(file='baz/f2.kt')]
ret = rh.hooks.check_ktfmt(self.project, 'commit', 'desc', diff,
options=rh.hooks.HookOptions('hook name', [
'--include-dirs=foo,baz'], {}))
- self.assertListEqual(ret[0].files, ['/.../repo/dir/foo/f1.kt',
- '/.../repo/dir/baz/f2.kt'])
+ self.assertListEqual(ret[0].files, ['foo/f1.kt', 'baz/f2.kt'])
def test_pylint(self, mock_check, _mock_run):
"""Verify the pylint builtin hook."""