[pim/akonadiclient] /: Add pre-commit CI support
Laurent Montel
null at kde.org
Thu Jun 12 06:03:59 BST 2025
Git commit 610d730f9da466a8a52cd2297eb15fec28503530 by Laurent Montel.
Committed on 12/06/2025 at 05:03.
Pushed by mlaurent into branch 'master'.
Add pre-commit CI support
A +95 -0 .clang-format-pre-commit
M +1 -3 .gitlab-ci.yml
A +59 -0 .pre-commit-config.yaml
M +52 -18 CMakeLists.txt
M +49 -29 CMakePresets.json
M +5 -5 COPYING
A +19 -0 LICENSES/MIT.txt
M +0 -1 config-akonadiclient.h.in
M +3 -3 doc/man-akonadiclient.1.docbook
M +13 -7 src/CMakeLists.txt
M +1 -1 src/abstractcommand.cpp
M +1 -1 src/folderscommand.cpp
https://invent.kde.org/pim/akonadiclient/-/commit/610d730f9da466a8a52cd2297eb15fec28503530
diff --git a/.clang-format-pre-commit b/.clang-format-pre-commit
new file mode 100644
index 0000000..9b5ae0a
--- /dev/null
+++ b/.clang-format-pre-commit
@@ -0,0 +1,95 @@
+---
+# SPDX-FileCopyrightText: 2019 Christoph Cullmann <cullmann at kde.org>
+# SPDX-FileCopyrightText: 2019 Gernot Gebhard <gebhard at absint.com>
+#
+# SPDX-License-Identifier: MIT
+
+# This file got automatically created by ECM, do not edit
+# See https://clang.llvm.org/docs/ClangFormatStyleOptions.html for the config options
+# and https://community.kde.org/Policies/Frameworks_Coding_Style#Clang-format_automatic_code_formatting
+# for clang-format tips & tricks
+---
+Language: JavaScript
+DisableFormat: true
+---
+Language: Json
+DisableFormat: false
+IndentWidth: 4
+---
+
+# Style for C++
+Language: Cpp
+
+# base is WebKit coding style: https://webkit.org/code-style-guidelines/
+# below are only things set that diverge from this style!
+BasedOnStyle: WebKit
+
+# enforce C++11 (e.g. for std::vector<std::vector<lala>>
+Standard: Cpp11
+
+# 4 spaces indent
+TabWidth: 4
+
+# 2 * 80 wide lines
+ColumnLimit: 160
+
+# sort includes inside line separated groups
+SortIncludes: true
+
+# break before braces on function, namespace and class definitions.
+BreakBeforeBraces: Linux
+
+# CrlInstruction *a;
+PointerAlignment: Right
+
+# horizontally aligns arguments after an open bracket.
+AlignAfterOpenBracket: Align
+
+# don't move all parameters to new line
+AllowAllParametersOfDeclarationOnNextLine: false
+
+# no single line functions
+AllowShortFunctionsOnASingleLine: None
+
+# no single line enums
+AllowShortEnumsOnASingleLine: false
+
+# always break before you encounter multi line strings
+AlwaysBreakBeforeMultilineStrings: true
+
+# don't move arguments to own lines if they are not all on the same
+BinPackArguments: false
+
+# don't move parameters to own lines if they are not all on the same
+BinPackParameters: false
+
+# In case we have an if statement with multiple lines the operator should be at the beginning of the line
+# but we do not want to break assignments
+BreakBeforeBinaryOperators: NonAssignment
+
+# format C++11 braced lists like function calls
+Cpp11BracedListStyle: true
+
+# do not put a space before C++11 braced lists
+SpaceBeforeCpp11BracedList: false
+
+# remove empty lines
+KeepEmptyLinesAtTheStartOfBlocks: false
+
+# no namespace indentation to keep indent level low
+NamespaceIndentation: None
+
+# we use template< without space.
+SpaceAfterTemplateKeyword: false
+
+# Always break after template declaration
+AlwaysBreakTemplateDeclarations: true
+
+# macros for which the opening brace stays attached.
+ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE , wl_resource_for_each, wl_resource_for_each_safe ]
+
+# keep lambda formatting multi-line if not empty
+AllowShortLambdasOnASingleLine: Empty
+
+# We do not want clang-format to put all arguments on a new line
+AllowAllArgumentsOnNextLine: false
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5ccb835..3985b2b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -7,8 +7,6 @@ include:
- /gitlab-templates/linux-qt6.yml
- /gitlab-templates/json-validation.yml
- /gitlab-templates/freebsd-qt6.yml
- - /gitlab-templates/clang-format.yml
- /gitlab-templates/windows-qt6.yml
- /gitlab-templates/craft-windows-x86-64-qt6.yml
- - /gitlab-templates/xml-lint.yml
- - /gitlab-templates/yaml-lint.yml
+ - /gitlab-templates/pre-commit.yml
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..80cff5e
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,59 @@
+# SPDX-FileCopyrightText: none
+# SPDX-License-Identifier: CC0-1.0
+# See https://pre-commit.com for more information
+# See https://pre-commit.com/hooks.html for more hooks
+
+exclude: (^po/|.desktop|Messages.sh)
+repos:
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v5.0.0
+ hooks:
+ - id: trailing-whitespace
+ - id: end-of-file-fixer
+ - id: check-added-large-files
+ - id: check-case-conflict
+ - id: check-xml
+ - id: check-yaml
+ args: [--allow-multiple-documents]
+ exclude: ^(.clang-tidy)
+ - id: check-json
+ - id: check-symlinks
+ - id: destroyed-symlinks
+ - id: check-executables-have-shebangs
+ - repo: https://github.com/pre-commit/mirrors-clang-format
+ rev: v20.1.4
+ hooks:
+ - id: clang-format
+ # force using this project's configuration rather
+ # than the one provided by CI
+ args: ["--style=file:.clang-format-pre-commit"]
+ - repo: https://github.com/astral-sh/ruff-pre-commit
+ # Ruff version.
+ rev: v0.11.9
+ hooks:
+ # Run the linter.
+ - id: ruff
+ # Run the formatter.
+ - id: ruff-format
+ - repo: https://github.com/codespell-project/codespell
+ rev: v2.4.1
+ hooks:
+ - id: codespell
+ exclude: (textemoticons/core/data/emoji.json|textgrammarcheck/grammalecte/autotests/data/result1.json|texttranslator/translator/plugins/bergamot/autotests/data/modellanguages/models.json|textgrammarcheck/languagetool/autotests/data/test2.json|textautocorrection/core/autotests/data/custom-fr-ref.xml|textgrammarcheck/common/autotests/grammarresultutiltest.cpp|textautocorrection/core/autotests/data/custom-fr.xml)
+ - repo: https://github.com/BlankSpruce/gersemi
+ rev: 0.19.3
+ hooks:
+ - id: gersemi
+ - repo: https://github.com/DavidAnson/markdownlint-cli2
+ rev: v0.18.1
+ hooks:
+ - id: markdownlint-cli2
+ files: \.(md|mdown|markdown)$
+ - repo: https://github.com/scop/pre-commit-shfmt
+ rev: v3.11.0-1
+ hooks:
+ - id: shfmt
+ - repo: https://github.com/shellcheck-py/shellcheck-py
+ rev: v0.10.0.1
+ hooks:
+ - id: shellcheck
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c9895bf..8077713 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,7 +4,9 @@ project(akonadiclient)
set(RELEASE_SERVICE_VERSION_MAJOR "24")
set(RELEASE_SERVICE_VERSION_MINOR "11")
set(RELEASE_SERVICE_VERSION_MICRO "70")
-set(RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
+set(RELEASE_SERVICE_VERSION
+ "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}"
+)
set(QT_MIN_VERSION "6.6.0")
set(KF_MIN_VERSION "6.2.3")
@@ -23,12 +25,33 @@ include(KDECMakeSettings)
include(ECMAddTests)
include(ECMQtDeclareLoggingCategory)
include(ECMDeprecationSettings)
-include(KDEGitCommitHooks)
-include(KDEClangFormat)
-configure_file(config-akonadiclient.h.in ${CMAKE_CURRENT_BINARY_DIR}/config-akonadiclient.h)
+configure_file(
+ config-akonadiclient.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/config-akonadiclient.h
+)
+file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h *.c)
+set(PRE_COMMIT_INSTALLED FALSE)
+if(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
+ if(EXISTS "${PROJECT_SOURCE_DIR}/.git/hooks/pre-commit")
+ file(READ "${PROJECT_SOURCE_DIR}/.git/hooks/pre-commit" FILE_CONTENTS)
+ string(FIND "${FILE_CONTENTS}" "File generated by pre-commit" INDEX)
+ if(${INDEX} GREATER_EQUAL 0)
+ set(PRE_COMMIT_INSTALLED TRUE)
+ endif()
+ endif()
+endif()
+if(NOT ${PRE_COMMIT_INSTALLED})
+ include(KDEGitCommitHooks)
+ include(KDEClangFormat)
+ kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
+endif()
-add_definitions(-DQT_USE_QSTRINGBUILDER -DQT_USE_FAST_OPERATOR_PLUS -DQT_NO_URL_CAST_FROM_STRING)
+add_definitions(
+ -DQT_USE_QSTRINGBUILDER
+ -DQT_USE_FAST_OPERATOR_PLUS
+ -DQT_NO_URL_CAST_FROM_STRING
+)
remove_definitions(-DQT_NO_CAST_FROM_ASCII)
remove_definitions(-DQT_NO_CAST_TO_ASCII)
add_definitions(-DTRANSLATION_DOMAIN=\"akonadiclient\")
@@ -37,33 +60,44 @@ find_package(KPim6Akonadi ${AKONADI_VERSION} CONFIG REQUIRED)
find_package(KPim6AkonadiContactCore ${AKONADI_CONTACT_VERSION} CONFIG REQUIRED)
find_package(KPim6Mime ${AKONADI_VERSION} CONFIG REQUIRED)
-find_package(Qt6 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Widgets Test)
+find_package(
+ Qt6
+ ${QT_MIN_VERSION}
+ REQUIRED
+ NO_MODULE
+ COMPONENTS Core Widgets Test
+)
find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS CoreAddons I18n Config)
# Only 'ncurses' includes terminfo support, not classic 'curses'
set(CURSES_NEED_NCURSES TRUE)
find_package(Curses)
-if (Curses_FOUND)
- set(HAVE_TERMINFO TRUE)
-endif ()
+if(Curses_FOUND)
+ set(HAVE_TERMINFO TRUE)
+endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR})
ecm_set_disabled_deprecation_versions(QT 6.9.0
KF 6.15.0
- )
+)
find_package(KF6DocTools ${KF_MIN_VERSION})
-set_package_properties(KF6DocTools PROPERTIES DESCRIPTION
- "Tools to generate documentation"
- TYPE OPTIONAL
+set_package_properties(
+ KF6DocTools
+ PROPERTIES DESCRIPTION "Tools to generate documentation" TYPE OPTIONAL
)
-
add_subdirectory(src)
ki18n_install(po)
if(KF6DocTools_FOUND)
- kdoctools_install(po)
- add_subdirectory(doc)
+ kdoctools_install(po)
+ add_subdirectory(doc)
endif()
-kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
-feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
+if(DEFINED kde_configure_git_pre_commit_hook)
+ kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
+endif()
+feature_summary(
+ WHAT ALL
+ INCLUDE_QUIET_PACKAGES
+ FATAL_ON_MISSING_REQUIRED_PACKAGES
+)
diff --git a/CMakePresets.json b/CMakePresets.json
index b3c6349..9016bcd 100644
--- a/CMakePresets.json
+++ b/CMakePresets.json
@@ -40,7 +40,7 @@
"displayName": "Build with Asan support.",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
- "ECM_ENABLE_SANITIZERS" : "'address;undefined'"
+ "ECM_ENABLE_SANITIZERS": "'address;undefined'"
},
"inherits": [
"base"
@@ -158,7 +158,7 @@
{
"name": "ftime-trace",
"configurePreset": "ftime-trace"
- },
+ },
{
"name": "dev-mold",
"configurePreset": "dev-mold"
@@ -191,35 +191,55 @@
"name": "clazy",
"configurePreset": "clazy",
"environment": {
[suppressed due to size limit]
- "CCACHE_DISABLE" : "ON"
[suppressed due to size limit]
+ "CCACHE_DISABLE": "ON"
}
}
],
"testPresets": [
- {
- "name": "dev",
- "configurePreset": "dev",
- "output": {"outputOnFailure": true},
- "execution": {"noTestsAction": "error", "stopOnFailure": false}
- },
- {
- "name": "asan",
- "configurePreset": "asan",
- "output": {"outputOnFailure": true},
- "execution": {"noTestsAction": "error", "stopOnFailure": true}
- },
- {
- "name": "unity",
- "configurePreset": "unity",
- "output": {"outputOnFailure": true},
- "execution": {"noTestsAction": "error", "stopOnFailure": true}
- },
- {
- "name": "coverage",
- "configurePreset": "coverage",
- "output": {"outputOnFailure": true},
- "execution": {"noTestsAction": "error", "stopOnFailure": true}
- }
- ]
+ {
+ "name": "dev",
+ "configurePreset": "dev",
+ "output": {
+ "outputOnFailure": true
+ },
+ "execution": {
+ "noTestsAction": "error",
+ "stopOnFailure": false
+ }
+ },
+ {
+ "name": "asan",
+ "configurePreset": "asan",
+ "output": {
+ "outputOnFailure": true
+ },
+ "execution": {
+ "noTestsAction": "error",
+ "stopOnFailure": true
+ }
+ },
+ {
+ "name": "unity",
+ "configurePreset": "unity",
+ "output": {
+ "outputOnFailure": true
+ },
+ "execution": {
+ "noTestsAction": "error",
+ "stopOnFailure": true
+ }
+ },
+ {
+ "name": "coverage",
+ "configurePreset": "coverage",
+ "output": {
+ "outputOnFailure": true
+ },
+ "execution": {
+ "noTestsAction": "error",
+ "stopOnFailure": true
+ }
+ }
+ ]
}
diff --git a/COPYING b/COPYING
index 5185fd3..1c7ce80 100644
--- a/COPYING
+++ b/COPYING
@@ -3,7 +3,7 @@ the instance of code that it refers to (the kde programs) are copyrighted
by the authors who actually wrote it.
---------------------------------------------------------------------------
-
+
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
@@ -61,7 +61,7 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
-
+
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@@ -116,7 +116,7 @@ above, provided that you also meet all of these conditions:
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
-
+
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
@@ -174,7 +174,7 @@ access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
-
+
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
@@ -231,7 +231,7 @@ impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
-
+
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt
new file mode 100644
index 0000000..204b93d
--- /dev/null
+++ b/LICENSES/MIT.txt
@@ -0,0 +1,19 @@
+MIT License Copyright (c) <year> <copyright holders>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/config-akonadiclient.h.in b/config-akonadiclient.h.in
index 2444070..a5a21af 100644
--- a/config-akonadiclient.h.in
+++ b/config-akonadiclient.h.in
@@ -5,4 +5,3 @@
*/
#define AKONADICLIENT_VERSION "${RELEASE_SERVICE_VERSION}"
-
diff --git a/doc/man-akonadiclient.1.docbook b/doc/man-akonadiclient.1.docbook
index 7847b21..c8c95ce 100644
--- a/doc/man-akonadiclient.1.docbook
+++ b/doc/man-akonadiclient.1.docbook
@@ -220,7 +220,7 @@ For example, adding items, collections, renaming or moving collections and also
<term><option>-m, --maildir</option></term>
<listitem><para>Dump email messages in maildir directory structure</para></listitem>
</varlistentry>
-
+
<varlistentry>
<term><option>-a, --akonadi-categories</option></term>
<listitem><para>Dump items with Akonadi categories, otherwise text</para></listitem>
@@ -290,7 +290,7 @@ For example, adding items, collections, renaming or moving collections and also
</variablelist>
</listitem>
</varlistentry>
-
+
<varlistentry>
<term><option>group</option></term>
<listitem>
@@ -303,7 +303,7 @@ For example, adding items, collections, renaming or moving collections and also
<term><option>-e, --expand</option></term>
<listitem><para>Show the expanded contact group (the default operation)</para></listitem>
</varlistentry>
-
+
<varlistentry>
<term><option>-a, --add</option></term>
<listitem><para>Add a contact to the group</para></listitem>
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a5ef058..701c222 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,6 +1,6 @@
-if (HAVE_TERMINFO)
- add_definitions("-DHAVE_TERMINFO")
-endif ()
+if(HAVE_TERMINFO)
+ add_definitions("-DHAVE_TERMINFO")
+endif()
###### library ######
@@ -37,12 +37,18 @@ set(libakonadiclient_SRCS
add_library(libakonadiclient STATIC)
target_sources(libakonadiclient PRIVATE ${libakonadiclient_SRCS})
-target_link_libraries(libakonadiclient KPim6::AkonadiCore KPim6::AkonadiXml KPim6::AkonadiContactCore KPim6::Mime)
+target_link_libraries(
+ libakonadiclient
+ KPim6::AkonadiCore
+ KPim6::AkonadiXml
+ KPim6::AkonadiContactCore
+ KPim6::Mime
+)
target_link_libraries(libakonadiclient KF6::I18n KF6::Codecs KF6::ConfigCore)
target_link_libraries(libakonadiclient Qt::Core)
-if (HAVE_TERMINFO)
- target_link_libraries(libakonadiclient ${CURSES_LIBRARIES})
-endif ()
+if(HAVE_TERMINFO)
+ target_link_libraries(libakonadiclient ${CURSES_LIBRARIES})
+endif()
set_target_properties(libakonadiclient PROPERTIES ENABLE_EXPORTS TRUE)
###### executable ######
diff --git a/src/abstractcommand.cpp b/src/abstractcommand.cpp
index 6419d17..fde4125 100644
--- a/src/abstractcommand.cpp
+++ b/src/abstractcommand.cpp
@@ -73,7 +73,7 @@ AbstractCommand::Error AbstractCommand::init(const QStringList &parsedArgs, bool
QString s = parser.helpText(); // parser is still available
// This substitutes the first "[options]" (between the "akonadiclient"
- // and the comand name) with blank, because it is not relevant and
+ // and the command name) with blank, because it is not relevant and
// would be confused with the command options (following the command
// name). Cannot use QString::replace() with a regular expression
// here, as that would substitute any subsequent "[optional]" help
diff --git a/src/folderscommand.cpp b/src/folderscommand.cpp
index ce4c337..04e9ef9 100644
--- a/src/folderscommand.cpp
+++ b/src/folderscommand.cpp
@@ -460,7 +460,7 @@ void FoldersCommand::processChanges()
continue;
// The key name pattern matched. Get the corresponding
- // value or list of values as appropriate. For simplicitly
+ // value or list of values as appropriate. For simplicity
// a single value is treated here as a one-item list,
// although it must be read as a single string value
// because it may contain a comma.
More information about the kde-doc-english
mailing list