From dca9fb2acffba56daddcf827d69fda88c0d7c4bd Mon Sep 17 00:00:00 2001 From: Jason Mobarak Date: Wed, 20 Sep 2023 13:19:40 -0700 Subject: [PATCH] feat: clang-format: add GIT_DESCRIBE_MATCH --- ClangFormat.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ClangFormat.cmake b/ClangFormat.cmake index 4f7c636..120d030 100644 --- a/ClangFormat.cmake +++ b/ClangFormat.cmake @@ -142,7 +142,7 @@ endmacro() # documentation in the file header. function(swift_setup_clang_format) set(argOption "REQUIRED") - set(argSingle "SCRIPT") + set(argSingle "SCRIPT" "GIT_DESCRIBE_MATCH") set(argMulti "CLANG_FORMAT_NAMES" "PATTERNS") cmake_parse_arguments(x "${argOption}" "${argSingle}" "${argMulti}" ${ARGN}) @@ -232,10 +232,16 @@ function(swift_setup_clang_format) set(patterns '*.[ch]' '*.cpp' '*.cc' '*.hpp') endif() + if(x_GIT_DESCRIBE_MATCH) + set(git_describe_match --match=${x_GIT_DESCRIBE_MATCH}) + else() + set(git_describe_match) + endif() + create_clang_format_targets( TOP_LEVEL ${top_level_project} ALL_COMMAND git ls-files ${patterns} | xargs -r ${${PROJECT_NAME}_CLANG_FORMAT} -i - DIFF_COMMAND git describe --tags --abbrev=0 --always + DIFF_COMMAND git describe --tags --abbrev=0 --always ${git_describe_match} | xargs -rI % git diff --diff-filter=ACMRTUXB --name-only --line-prefix=`git rev-parse --show-toplevel`/ % -- ${patterns} | xargs -r ${${PROJECT_NAME}_CLANG_FORMAT} -i )