diff options
author | Brad King <brad.king@kitware.com> | 2016-04-05 13:38:06 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-04-05 13:38:06 (GMT) |
commit | fd40b0f875db35b9eaf214fd1013277d1801d589 (patch) | |
tree | f88a7ade0fb777c4448ef3e5a8d67bc69783cb81 /Source/CTest | |
parent | 25a38ecfe7beffe2a2adf522414288810cdc1006 (diff) | |
parent | c18d91add836f7ce426fcb59b2c65235898f3979 (diff) | |
download | CMake-fd40b0f875db35b9eaf214fd1013277d1801d589.zip CMake-fd40b0f875db35b9eaf214fd1013277d1801d589.tar.gz CMake-fd40b0f875db35b9eaf214fd1013277d1801d589.tar.bz2 |
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
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestGIT.cxx | 47 | ||||
-rw-r--r-- | Source/CTest/cmCTestUpdateCommand.cxx | 2 |
2 files changed, 45 insertions, 4 deletions
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index bbb3b9d..1d6bdce 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -273,21 +273,60 @@ bool cmCTestGIT::UpdateImpl() std::string top_dir = this->FindTopDir(); const char* git = this->CommandLineTool.c_str(); 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)) { 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())) { - 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_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, top_dir.c_str()); } diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index dfda9f1..1bf60fc 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -55,6 +55,8 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler() this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS", this->Quiet); this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "GITInitSubmodules", "CTEST_GIT_INIT_SUBMODULES", this->Quiet); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "GITUpdateCustom", "CTEST_GIT_UPDATE_CUSTOM", this->Quiet); this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "UpdateVersionOnly", "CTEST_UPDATE_VERSION_ONLY", this->Quiet); |