diff options
author | Brad King <brad.king@kitware.com> | 2020-12-02 13:55:09 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-12-02 16:27:39 (GMT) |
commit | 26ec2e2b0cfee6424290103b5f947bd171ac55a9 (patch) | |
tree | d4532291d9dbeb333808859d4923635298f65edc /Tests/CTestUpdateGIT.cmake.in | |
parent | c30b65305e159418845f0d98deeb32ae18e00c1a (diff) | |
download | CMake-26ec2e2b0cfee6424290103b5f947bd171ac55a9.zip CMake-26ec2e2b0cfee6424290103b5f947bd171ac55a9.tar.gz CMake-26ec2e2b0cfee6424290103b5f947bd171ac55a9.tar.bz2 |
Tests: Update CTest.UpdateGIT test for custom defaultBranch
Git installation now prompts the user to choose a system-wide
name for the default branch in new repositories.
Diffstat (limited to 'Tests/CTestUpdateGIT.cmake.in')
-rw-r--r-- | Tests/CTestUpdateGIT.cmake.in | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/Tests/CTestUpdateGIT.cmake.in b/Tests/CTestUpdateGIT.cmake.in index 7d0fa0f..a3ef4eb 100644 --- a/Tests/CTestUpdateGIT.cmake.in +++ b/Tests/CTestUpdateGIT.cmake.in @@ -32,6 +32,20 @@ if(UNIX) set(GIT ${TOP}/git.sh) endif() +# Adapt to the system default branch name. +execute_process( + COMMAND ${GIT} config --get init.defaultBranch + RESULT_VARIABLE defaultBranchFailed + OUTPUT_VARIABLE defaultBranch + ERROR_VARIABLE defaultBranchError + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_STRIP_TRAILING_WHITESPACE + ) +if(defaultBranch STREQUAL "") + set(defaultBranch master) +endif() +message("Detected default branch name '${defaultBranch}'") + #----------------------------------------------------------------------------- # Create the repository. message("Creating repository...") @@ -64,7 +78,7 @@ run_child(WORKING_DIRECTORY ${TOP}/module COMMAND ${GIT} commit -m "Initial content" ) run_child(WORKING_DIRECTORY ${TOP}/module - COMMAND ${GIT} push origin master:refs/heads/master + COMMAND ${GIT} push origin ${defaultBranch}:refs/heads/${defaultBranch} ) #----------------------------------------------------------------------------- @@ -80,7 +94,7 @@ file(APPEND ${TOP}/import/.git/config " ${AUTHOR_CONFIG}") create_content(import) file(WRITE ${TOP}/import/HEAD "HEAD\n") -file(WRITE ${TOP}/import/master "master\n") +file(WRITE ${TOP}/import/${defaultBranch} "${defaultBranch}\n") run_child(WORKING_DIRECTORY ${TOP}/import COMMAND ${GIT} add . ) @@ -94,7 +108,7 @@ run_child(WORKING_DIRECTORY ${TOP}/import COMMAND ${GIT} commit -m "Initial content" ) run_child(WORKING_DIRECTORY ${TOP}/import - COMMAND ${GIT} push origin master:refs/heads/master + COMMAND ${GIT} push origin ${defaultBranch}:refs/heads/${defaultBranch} ) #----------------------------------------------------------------------------- @@ -107,7 +121,7 @@ run_child(WORKING_DIRECTORY ${TOP}/module COMMAND ${GIT} commit -m "Changed content" ) run_child(WORKING_DIRECTORY ${TOP}/module - COMMAND ${GIT} push origin master:refs/heads/master + COMMAND ${GIT} push origin ${defaultBranch}:refs/heads/${defaultBranch} ) #----------------------------------------------------------------------------- @@ -163,7 +177,7 @@ run_child( COMMAND ${GIT} rm -- ${files_removed} ) run_child(WORKING_DIRECTORY ${TOP}/user-source/module - COMMAND ${GIT} checkout master -- + COMMAND ${GIT} checkout ${defaultBranch} -- ) run_child( WORKING_DIRECTORY ${TOP}/user-source @@ -222,7 +236,7 @@ rewind_source(user-source) # modified files) even if ~/.gitconfig sets "branch.master.rebase". run_child( WORKING_DIRECTORY ${TOP}/user-source - COMMAND ${GIT} config branch.master.rebase false + COMMAND ${GIT} config branch.${defaultBranch}.rebase false ) # Create a modified file. @@ -254,7 +268,7 @@ create_build_tree(user-source user-binary-custom) file(APPEND ${TOP}/user-binary-custom/CTestConfiguration.ini "# GIT command configuration UpdateCommand: ${GIT} -GITUpdateCustom: ${GIT};pull;origin;master +GITUpdateCustom: ${GIT};pull;origin;${defaultBranch} ") # Run the dashboard command line interface. @@ -304,7 +318,7 @@ create_dashboard_script(dash-binary-custom "# git command configuration set(CTEST_GIT_COMMAND \"${GIT}\") set(CTEST_GIT_UPDATE_OPTIONS) -set(CTEST_GIT_UPDATE_CUSTOM \${CTEST_GIT_COMMAND} pull origin master) +set(CTEST_GIT_UPDATE_CUSTOM \${CTEST_GIT_COMMAND} pull origin ${defaultBranch}) ") # Run the dashboard script with CTest. @@ -339,7 +353,7 @@ create_dashboard_script(dash-binary-quiet "# git command configuration set(CTEST_GIT_COMMAND \"${GIT}\") set(CTEST_GIT_UPDATE_OPTIONS) -set(CTEST_GIT_UPDATE_CUSTOM \${CTEST_GIT_COMMAND} pull origin master) +set(CTEST_GIT_UPDATE_CUSTOM \${CTEST_GIT_COMMAND} pull origin ${defaultBranch}) ") unset(ctest_update_args) |