Files
qt5/cmake/QtSynchronizeRepo.cmake
Alexandru Croitor 89b1d7f86c CMake: Add support for a git qt-foreach subcommand for worktrees
Developers that use a top-level qt5.git can use git submodule foreach
to run commands for each submodule. That is not available to
developers that maintain their own non-submodule based top-level
checkout using git worktrees.

Extend the QtSynchronizeRepo.cmake script that allows to sync
submodules / worktrees to also allow running foreach commands.

The CMake invocation to run a foreach would look like

  cmake -DQT_FOREACH=TRUE "-DARGS=git pull -r" -P
    cmake/QtSynchronizeRepo.cmake

But it's nicer to create a git-qt-foreach script in
/usr/local/bin/git-qt-foreach with the following contents

 cmake -DQT_FOREACH=TRUE "-DARGS=$*" -P cmake/QtSynchronizeRepo.cmake

Make sure to chmod a+x it and invoke like

git qt-foreach git pull -r

Change-Id: I0ccd67facbfe702c6a872165cdfd9f9e6eae9043
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-27 10:44:08 +01:00

13 lines
504 B
CMake

# This script is to be called (ideally from a git-sync-to alias script):
# cmake -DSYNC_TO_MODULE="$1" -DSYNC_TO_BRANCH="$2" -P cmake/QtSynchronizeRepo.cmake
# Or as follows (ideally from a git-qt-foreach alias script):
# cmake -DQT_FOREACH=TRUE "-DARGS=$*" -P cmake/QtSynchronizeRepo.cmake
cmake_policy(VERSION 3.16)
include(cmake/QtTopLevelHelpers.cmake)
if(QT_FOREACH)
qt_internal_foreach_repo_run(ARGS ${ARGS})
else()
qt_internal_sync_to(${SYNC_TO_MODULE} ${SYNC_TO_BRANCH})
endif()