Bug 472361

Summary: Allow KDEGitCommitHooks to work with external commit hooks
Product: [Frameworks and Libraries] extra-cmake-modules Reporter: Johannes Zarl-Zierl <johannes>
Component: generalAssignee: Alexander Lohnau <alexander.lohnau>
Status: RESOLVED FIXED    
Severity: normal CC: alexander.lohnau
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 5.109
Sentry Crash Report:

Description Johannes Zarl-Zierl 2023-07-18 14:58:32 UTC
SUMMARY

As just discussed in the Automation BoF: At KPhotoAlbum we already have some git commit hooks that we use:
https://invent.kde.org/graphics/kphotoalbum/-/tree/master/dev

It would be nice to be able to continue to have our own commit hooks, plus use KDEGitCommitHooks in parallel and have both sets of commit hooks run.
Comment 1 Alexander Lohnau 2023-07-18 18:23:24 UTC
I have misremembered when I said one can't use a custom hook – in case one has a preexisting hook, the defined hooks are appended.

Though AFAICS this would not work in case a hook from KDEGitCommitHooks is removed, because we would not remove it from the script. So having the file entirely generated and adding custom scripts through the CMake function is reasonable either way.
Comment 2 Alexander Lohnau 2023-07-18 19:07:58 UTC
I wonder if we should target kf5 for this, because consumers should be able to use it in both for 5 and 6 based apps.
If it were to only exist in KF6, it would not always be set, but rather depend on the used major version of Qt.
Comment 3 Bug Janitor Service 2023-07-19 06:09:13 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/extra-cmake-modules/-/merge_requests/366
Comment 4 Alexander Lohnau 2023-07-19 17:45:46 UTC
Git commit 072f57dbb641caa793cbcf359091439fe0dccef4 by Alexander Lohnau.
Committed on 19/07/2023 at 15:33.
Pushed by alex into branch 'master'.

KDEGitCommitHooks: Allow passing in of custom scripts

In case of kphotoalbum, the maintainer wants the clang-format hook in
addition to a set of custom hooks. While we currently append to the file
in case it exists, it would still mean that custom hooks have to be
installed/configured separately.

Because developers can not specify custom hooks, we can just override
the file which will make the entire generation process easier.
Since this is a small behavior change, it is put in a version guard.
FIXED-IN: 5.109

M  +39   -29   kde-modules/KDEGitCommitHooks.cmake
M  +1    -1    kde-modules/kde-git-commit-hooks/pre-commit.in

https://invent.kde.org/frameworks/extra-cmake-modules/-/commit/072f57dbb641caa793cbcf359091439fe0dccef4
Comment 5 Alexander Lohnau 2023-07-21 17:26:48 UTC
Git commit c8a17d979af91554cf8a0e31bc68ed9336f14f4f by Alexander Lohnau.
Committed on 21/07/2023 at 17:26.
Pushed by alex into branch 'kf5'.

KDEGitCommitHooks: Allow passing in of custom scripts

In case of kphotoalbum, the maintainer wants the clang-format hook in
addition to a set of custom hooks. While we currently append to the file
in case it exists, it would still mean that custom hooks have to be
installed/configured separately.

Because developers can not specify custom hooks, we can just override
the file which will make the entire generation process easier.
Since this is a small behavior change, it is put in a version guard.
FIXED-IN: 5.109


(cherry picked from commit 072f57dbb641caa793cbcf359091439fe0dccef4)

M  +39   -29   kde-modules/KDEGitCommitHooks.cmake
M  +1    -1    kde-modules/kde-git-commit-hooks/pre-commit.in

https://invent.kde.org/frameworks/extra-cmake-modules/-/commit/c8a17d979af91554cf8a0e31bc68ed9336f14f4f