Merge topic 'ctest-run-submodule-sync'

c18d91ad Help: add release notes for topic 'ctest-run-submodule-sync'
7f560743 cmCTestGIT: run `git submodule sync` before updating submodules
06b310b5 cmCTestGIT: add an option to initialize submodules on update
56c1ea40 cmCTestGIT: fix git version references
This commit is contained in:
Brad King 2016-04-05 09:38:06 -04:00 committed by CMake Topic Stage
commit fd40b0f875
7 changed files with 67 additions and 4 deletions

View File

@ -407,6 +407,7 @@ Variables for CTest
/variable/CTEST_DROP_SITE_USER /variable/CTEST_DROP_SITE_USER
/variable/CTEST_EXTRA_COVERAGE_GLOB /variable/CTEST_EXTRA_COVERAGE_GLOB
/variable/CTEST_GIT_COMMAND /variable/CTEST_GIT_COMMAND
/variable/CTEST_GIT_INIT_SUBMODULES
/variable/CTEST_GIT_UPDATE_CUSTOM /variable/CTEST_GIT_UPDATE_CUSTOM
/variable/CTEST_GIT_UPDATE_OPTIONS /variable/CTEST_GIT_UPDATE_OPTIONS
/variable/CTEST_HG_COMMAND /variable/CTEST_HG_COMMAND

View File

@ -589,6 +589,12 @@ Configuration settings to specify the version control tool include:
* `CTest Script`_ variable: :variable:`CTEST_GIT_COMMAND` * `CTest Script`_ variable: :variable:`CTEST_GIT_COMMAND`
* :module:`CTest` module variable: ``GITCOMMAND`` * :module:`CTest` module variable: ``GITCOMMAND``
``GITInitSubmodules``
If set, CTest will update the repository's submodules before updating.
* `CTest Script`_ variable: :variable:`CTEST_GIT_INIT_SUBMODULES`
* :module:`CTest` module variable: ``CTEST_GIT_INIT_SUBMODULES``
``GITUpdateCustom`` ``GITUpdateCustom``
Specify a custom command line (as a semicolon-separated list) to run Specify a custom command line (as a semicolon-separated list) to run
in the source tree (Git work tree) to update it instead of running in the source tree (Git work tree) to update it instead of running

View File

@ -0,0 +1,9 @@
ctest-run-submodule-sync
------------------------
* The :command:`ctest_update` command now looks at the
:variable:`CTEST_GIT_INIT_SUBMODULES` variable to determine whether
submodules should be updated or not before updating.
* The :command:`ctest_update` command will now synchronize submodules on an
update. Updates which add submodules or change a submodule's URL will now be
pulled properly.

View File

@ -0,0 +1,5 @@
CTEST_GIT_INIT_SUBMODULES
-------------------------
Specify the CTest ``GITInitSubmodules`` setting
in a :manual:`ctest(1)` dashboard client script.

View File

@ -52,6 +52,7 @@ SVNUpdateOptions: @SVN_UPDATE_OPTIONS@
# Git options # Git options
GITCommand: @GITCOMMAND@ GITCommand: @GITCOMMAND@
GITInitSubmodules: @CTEST_GIT_INIT_SUBMODULES@
GITUpdateOptions: @GIT_UPDATE_OPTIONS@ GITUpdateOptions: @GIT_UPDATE_OPTIONS@
GITUpdateCustom: @CTEST_GIT_UPDATE_CUSTOM@ GITUpdateCustom: @CTEST_GIT_UPDATE_CUSTOM@

View File

@ -273,21 +273,60 @@ bool cmCTestGIT::UpdateImpl()
std::string top_dir = this->FindTopDir(); std::string top_dir = this->FindTopDir();
const char* git = this->CommandLineTool.c_str(); const char* git = this->CommandLineTool.c_str();
const char* recursive = "--recursive"; const char* recursive = "--recursive";
const char* sync_recursive = "--recursive";
// Git < 1.6.5.0 did not support --recursive // Git < 1.6.5 did not support submodule --recursive
if(this->GetGitVersion() < cmCTestGITVersion(1,6,5,0)) if(this->GetGitVersion() < cmCTestGITVersion(1,6,5,0))
{ {
recursive = 0; recursive = 0;
// No need to require >= 1.6.5.0 if there are no submodules. // No need to require >= 1.6.5 if there are no submodules.
if(cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) if(cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str()))
{ {
this->Log << "Git < 1.6.5.0 cannot update submodules recursively\n"; this->Log << "Git < 1.6.5 cannot update submodules recursively\n";
}
}
// Git < 1.8.1 did not support sync --recursive
if(this->GetGitVersion() < cmCTestGITVersion(1,8,1,0))
{
sync_recursive = 0;
// No need to require >= 1.8.1 if there are no submodules.
if(cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str()))
{
this->Log << "Git < 1.8.1 cannot synchronize submodules recursively\n";
} }
} }
char const* git_submodule[] = {git, "submodule", "update", recursive, 0};
OutputLogger submodule_out(this->Log, "submodule-out> "); OutputLogger submodule_out(this->Log, "submodule-out> ");
OutputLogger submodule_err(this->Log, "submodule-err> "); OutputLogger submodule_err(this->Log, "submodule-err> ");
bool ret;
std::string init_submodules =
this->CTest->GetCTestConfiguration("GITInitSubmodules");
if (cmSystemTools::IsOn(init_submodules.c_str()))
{
char const* git_submodule_init[] = {git, "submodule", "init", 0};
ret = this->RunChild(git_submodule_init, &submodule_out, &submodule_err,
top_dir.c_str());
if (!ret)
{
return false;
}
}
char const* git_submodule_sync[] = {git, "submodule", "sync",
sync_recursive, 0};
ret = this->RunChild(git_submodule_sync, &submodule_out, &submodule_err,
top_dir.c_str());
if (!ret)
{
return false;
}
char const* git_submodule[] = {git, "submodule", "update", recursive, 0};
return this->RunChild(git_submodule, &submodule_out, &submodule_err, return this->RunChild(git_submodule, &submodule_out, &submodule_err,
top_dir.c_str()); top_dir.c_str());
} }

View File

@ -54,6 +54,8 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler()
"GITCommand", "CTEST_GIT_COMMAND", this->Quiet); "GITCommand", "CTEST_GIT_COMMAND", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS", this->Quiet); "GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"GITInitSubmodules", "CTEST_GIT_INIT_SUBMODULES", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"GITUpdateCustom", "CTEST_GIT_UPDATE_CUSTOM", this->Quiet); "GITUpdateCustom", "CTEST_GIT_UPDATE_CUSTOM", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,