Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: clang-format: add GIT_DESCRIBE_MATCH #168

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ClangFormat.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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
)
Expand Down
Loading