From 846b7988cf62bcee4fbcd463b648773143c466d2 Mon Sep 17 00:00:00 2001
From: Jordan Demeulenaere <jdemeulenaere@google.com>
Date: Wed, 29 May 2024 15:22:56 +0200
Subject: [PATCH] Replace ktfmt.py hook by built-in hook in SystemUI/

This CL replaces the ktfmt.py hook of this repository by the builtin
ktfmt hook. This will allow to delete our custom hook and provide
features like automatic fixup (see http://screen/5uXuuPgs7oL83c2).

Note that this also means that this CL is upgrading ktfmt from v0.43 to
v0.49, so it is expected to see some minor formatting diffs on existing
files after this CL is submitted.

Bug: 342153000
Test: N/A
Flag: NONE Repohook Update
Change-Id: I62d20facadc82b542b008afca4f28aaad80eaf2c
---
 PREUPLOAD.cfg      | 7 +++++--
 ktfmt_includes.txt | 2 --
 2 files changed, 5 insertions(+), 4 deletions(-)
 delete mode 100644 ktfmt_includes.txt

diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index b42f7bc0ca94..e8571757c6f7 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -1,6 +1,7 @@
 [Builtin Hooks]
 clang_format = true
 bpfmt = true
+ktfmt = true
 
 [Builtin Hooks Options]
 # Only turn on clang-format check for the following subfolders.
@@ -17,6 +18,7 @@ clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp
                tests/
                tools/
 bpfmt = -d
+ktfmt = --kotlinlang-style --include-dirs=services/permission,packages/SystemUI
 
 [Hook Scripts]
 checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
@@ -25,9 +27,10 @@ hidden_api_txt_checksorted_hook = ${REPO_ROOT}/tools/platform-compat/hiddenapi/c
 
 hidden_api_txt_exclude_hook = ${REPO_ROOT}/frameworks/base/tools/hiddenapi/exclude.sh ${PREUPLOAD_COMMIT} ${REPO_ROOT}
 
-ktfmt_hook = ${REPO_ROOT}/external/ktfmt/ktfmt.py --check -i ${REPO_ROOT}/frameworks/base/ktfmt_includes.txt ${PREUPLOAD_FILES}
-
 ktlint_hook = ${REPO_ROOT}/prebuilts/ktlint/ktlint.py --no-verify-format -f ${PREUPLOAD_FILES}
 
 # This flag check hook runs only for "packages/SystemUI" subdirectory. If you want to include this check for other subdirectories, please modify flag_check.py.
 flag_hook = ${REPO_ROOT}/frameworks/base/packages/SystemUI/flag_check.py --msg=${PREUPLOAD_COMMIT_MESSAGE} --files=${PREUPLOAD_FILES} --project=${REPO_PATH}
+
+[Tool Paths]
+ktfmt = ${REPO_ROOT}/prebuilts/build-tools/common/framework/ktfmt.jar
diff --git a/ktfmt_includes.txt b/ktfmt_includes.txt
deleted file mode 100644
index caf7874f07f5..000000000000
--- a/ktfmt_includes.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-+services/permission
-+packages/SystemUI
-- 
GitLab