Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add git version info for parent commits (#597) #598

Merged
merged 32 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
00b3c6f
Add test TribitsHelloWorld_config_git_version (#597)
bartlettroscoe Jan 4, 2024
80191d4
Print the stdout/stderr from the failed git command (#587)
bartlettroscoe Jan 4, 2024
98750bb
Strip the whitespace from git command (#597)
bartlettroscoe Jan 4, 2024
1db9378
Add check of generatead TribitsHelloWorldRepoVersion.txt file (#597)
bartlettroscoe Jan 4, 2024
ebd6c6f
Renamed test TribitsHelloWorld_config_git_version (#597)
achauphan Jan 11, 2024
b35e3c9
Refactored chunk of tribits_generate_single_repo_version_string for r…
achauphan Jan 11, 2024
8966263
Removed trailing whitespace for tribits_git_repo_sha1 git cmnd output…
achauphan Jan 12, 2024
fd3a2e9
Add commit sha1 input for tribits_generate_commit_info_string (#597)
achauphan Jan 12, 2024
be3a494
Updated TribitsHelloWorld_config_git_version_single_repo_one_parent t…
achauphan Jan 12, 2024
0dacf47
Added git version info for parent commits (#597)
achauphan Jan 13, 2024
f34a429
Added double quotes around variable (#597)
achauphan Jan 13, 2024
3af75e3
Fix type causing sphinx build to fail (#597)
achauphan Jan 13, 2024
a40bd5e
Added global cmake cache var to show git commit parents (#597)
achauphan Jan 16, 2024
592ea0d
Cleaned up git log and cmake command argument formatting (#597)
achauphan Jan 16, 2024
e4b19b6
Updated tribits_gernerate_single_repo_version_string to use HEAD (#597)
achauphan Jan 16, 2024
852e651
Updated to use cmake string(REGEX REPLACE) when converting git log ou…
achauphan Jan 16, 2024
f6b6442
Simplified loop and changed to 1-based indexing (#597)
achauphan Jan 16, 2024
1e5e09e
Implemented -DPROJECT_NAME_SHOW_GIT_COMMIT_PARENTS option (#597)
achauphan Jan 24, 2024
de652b7
Reorder functions according to clean code ordering (#597)
bartlettroscoe Jan 24, 2024
ba7e8da
Cleaned up empty lines (#597)
achauphan Jan 17, 2024
628b27e
Add missing () on function block doc (#597)
bartlettroscoe Jan 24, 2024
ce4728b
Switch to one_value_keywords for INCLUDE_COMMIT_PARENTS (#597)
bartlettroscoe Jan 24, 2024
1548b6f
Speed up Git version info test by setting <Project>_TRACE_DEPENDENCY_…
bartlettroscoe Jan 24, 2024
3aa1ea8
Document <Project>_TRACE_DEPENDENCY_HANDLING_ONLY (#597)
bartlettroscoe Jan 24, 2024
b9e7d10
Refactor tribits_generate_repo_version_file_string() naming and clean…
bartlettroscoe Jan 24, 2024
e30b76e
Move TribitsGitRepoVersionInfo.cmake from core/package_arch/ to core/…
bartlettroscoe Jan 24, 2024
3bed1f9
Use tribits_advanced_set_cache_var_and_default() for <Project>_SHOW_G…
bartlettroscoe Jan 24, 2024
ba27309
Document setting <Project>_SHOW_GIT_COMMIT_PARENTS_DEFAULT in users/m…
bartlettroscoe Jan 24, 2024
731841e
Fix some typos in tribits_ctest_driver() (#597)
bartlettroscoe Jan 24, 2024
548a0b9
Set -DTribitsExMetaProj_SHOW_GIT_COMMIT_PARENTS=ON for multi-repo tes…
bartlettroscoe Jan 24, 2024
da80610
Merge pull request #601 from bartlettroscoe/597-config-git-version-in…
bartlettroscoe Jan 25, 2024
2f17d8e
Merge branch 'master' into 597-config-git-version-info
bartlettroscoe Jan 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(TribitsHelloWorld_COMMON_CONFIG_ARGS
${SERIAL_PASSTHROUGH_CONFIGURE_ARGS}
)


tribits_add_advanced_test( TribitsHelloWorld
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1
Expand Down Expand Up @@ -36,6 +37,115 @@ tribits_add_advanced_test( TribitsHelloWorld
)


tribits_add_advanced_test( TribitsHelloWorld_config_git_version_single_repo_one_parent
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1
XHOST Windows # We use the 'diff' command below :-(

TEST_0
MESSAGE "Copy the project source so we can copy files into it."
CMND ${CMAKE_COMMAND}
ARGS -E copy_directory
${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsHelloWorld
TribitsHelloWorld

TEST_1
MESSAGE "Create a dummy .git directory so it will run git commands"
CMND ${CMAKE_COMMAND} ARGS -E make_directory TribitsHelloWorld/.git

TEST_2
CMND ${CMAKE_COMMAND} ARGS -E copy
${CMAKE_CURRENT_SOURCE_DIR}/configure_git_mockprogram_files/mockprogram_inout.single_repo_one_parent_version.txt
TribitsHelloWorld/.mockprogram_inout.txt

TEST_3
WORKING_DIRECTORY BUILD
CMND ${CMAKE_COMMAND}
ARGS
${TribitsHelloWorld_COMMON_CONFIG_ARGS}
-DTribitsHelloWorld_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}
-DTribitsHelloWorld_ENABLE_TESTS=ON
-DTribitsHelloWorld_GENERATE_REPO_VERSION_FILE=ON
-DTribitsHelloWorld_TRACE_DEPENDENCY_HANDLING_ONLY=ON
-DGIT_EXECUTABLE=${${PROJECT_NAME}_TRIBITS_DIR}/python_utils/mockprogram.py
../TribitsHelloWorld
PASS_REGULAR_EXPRESSION_ALL
"a1234tgb .Thu Sep 21 19:19:18 2023 -0400. <[email protected]>"
"This is the HEAD commit summary line"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_4
CMND diff ARGS
${CMAKE_CURRENT_SOURCE_DIR}/configure_git_mockprogram_files/TribitsHelloWorldRepoVersion.single_repo_one_parent_version.txt
BUILD/TribitsHelloWorldRepoVersion.txt

)
# NOTES:
#
# * The above directory structure is:
#
# TribitsHelloWorld_config_git_version_single_repo_one_parent/
# TribitsHelloWorld/
# .git/
# .mockprogram_inout.txt
# BUILD/
#
# * We don't use cmake -E compare_files because it does not print the diff,
# just gives a non-zero error code.


tribits_add_advanced_test( TribitsHelloWorld_config_git_version_single_repo_two_parents
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1
XHOST Windows # We use the 'diff' command below :-(

TEST_0
MESSAGE "Copy the project source so we can copy files into it."
CMND ${CMAKE_COMMAND}
ARGS -E copy_directory
${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsHelloWorld
TribitsHelloWorld

TEST_1
MESSAGE "Create a dummy .git directory so it will run git commands"
CMND ${CMAKE_COMMAND} ARGS -E make_directory TribitsHelloWorld/.git

TEST_2
CMND ${CMAKE_COMMAND} ARGS -E copy
${CMAKE_CURRENT_SOURCE_DIR}/configure_git_mockprogram_files/mockprogram_inout.single_repo_two_parents_version.txt
TribitsHelloWorld/.mockprogram_inout.txt

TEST_3
WORKING_DIRECTORY BUILD
CMND ${CMAKE_COMMAND}
ARGS
${TribitsHelloWorld_COMMON_CONFIG_ARGS}
-DTribitsHelloWorld_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}
-DTribitsHelloWorld_ENABLE_TESTS=ON
-DTribitsHelloWorld_GENERATE_REPO_VERSION_FILE=ON
-DTribitsHelloWorld_TRACE_DEPENDENCY_HANDLING_ONLY=ON
-DTribitsHelloWorld_SHOW_GIT_COMMIT_PARENTS=ON
-DGIT_EXECUTABLE=${${PROJECT_NAME}_TRIBITS_DIR}/python_utils/mockprogram.py
../TribitsHelloWorld
PASS_REGULAR_EXPRESSION_ALL
"a1234tgb .Thu Sep 21 19:19:18 2023 -0400. <[email protected]>"
"This is the HEAD commit summary line"
"Parent 1:"
"b5678aop .Thu Sep 20 19:19:18 2023 -0400. <[email protected]>"
"This is parent 1 commit summary line"
"Parent 2:"
"c9101hah .Thu Sep 19 19:19:18 2023 -0400. <[email protected]>"
"This is parent 2 commit summary line"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_4
CMND diff ARGS
${CMAKE_CURRENT_SOURCE_DIR}/configure_git_mockprogram_files/TribitsHelloWorldRepoVersion.single_repo_two_parents_version.txt
BUILD/TribitsHelloWorldRepoVersion.txt

)


tribits_add_advanced_test( TribitsHelloWorld_EXE_DISABLE
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*** Base Git Repo: TribitsHelloWorld
a1234tgb [Thu Sep 21 19:19:18 2023 -0400] <[email protected]>
This is the HEAD commit summary line
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*** Base Git Repo: TribitsHelloWorld
a1234tgb [Thu Sep 21 19:19:18 2023 -0400] <[email protected]>
This is the HEAD commit summary line
*** Parent 1:
achauphan marked this conversation as resolved.
Show resolved Hide resolved
b5678aop [Thu Sep 20 19:19:18 2023 -0400] <[email protected]>
This is parent 1 commit summary line
*** Parent 2:
c9101hah [Thu Sep 19 19:19:18 2023 -0400] <[email protected]>
This is parent 2 commit summary line
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%h [%ad] <%ae> HEAD
MOCK_PROGRAM_RETURN: 0
MOCK_PROGRAM_OUTPUT: a1234tgb [Thu Sep 21 19:19:18 2023 -0400] <[email protected]>
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%s HEAD
MOCK_PROGRAM_RETURN: 0
MOCK_PROGRAM_OUTPUT: This is the HEAD commit summary line
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%p HEAD
MOCK_PROGRAM_RETURN: 0
MOCK_PROGRAM_OUTPUT: b5678aop
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%h [%ad] <%ae> HEAD
MOCK_PROGRAM_RETURN: 0
MOCK_PROGRAM_OUTPUT: a1234tgb [Thu Sep 21 19:19:18 2023 -0400] <[email protected]>
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%s HEAD
MOCK_PROGRAM_RETURN: 0
MOCK_PROGRAM_OUTPUT: This is the HEAD commit summary line
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%p HEAD
MOCK_PROGRAM_RETURN: 0
MOCK_PROGRAM_OUTPUT: b5678aop c9101hah
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%h [%ad] <%ae> b5678aop
MOCK_PROGRAM_RETURN: 0
MOCK_PROGRAM_OUTPUT: b5678aop [Thu Sep 20 19:19:18 2023 -0400] <[email protected]>
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%s b5678aop
MOCK_PROGRAM_RETURN: 0
MOCK_PROGRAM_OUTPUT: This is parent 1 commit summary line
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%h [%ad] <%ae> c9101hah
MOCK_PROGRAM_RETURN: 0
MOCK_PROGRAM_OUTPUT: c9101hah [Thu Sep 19 19:19:18 2023 -0400] <[email protected]>
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%s c9101hah
MOCK_PROGRAM_RETURN: 0
MOCK_PROGRAM_OUTPUT: This is parent 2 commit summary line
5 changes: 3 additions & 2 deletions test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re
${COMMON_ENV_ARGS}
TribitsExMetaProj_ENABLE_SECONDARY_TESTED_CODE=TRUE
CTEST_BUILD_NAME=CTestDriver_TribitsExMetaProj_clone_default_branch_remote
TribitsExMetaProj_EXTRA_CONFIGURE_OPTIONS=-DTribitsExMetaProj_SHOW_GIT_COMMIT_PARENTS=ON
CTEST_SITE=CustomSite
${CTEST_S_SCRIPT_ARGS}
PASS_REGULAR_EXPRESSION_ALL
Expand Down Expand Up @@ -262,7 +263,7 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re
TEST_8
MESSAGE "Make sure that the file TribitsExMetaProjRepoVersion.txt is correct"
CMND diff ARGS
"${CMAKE_CURRENT_LIST_DIR}/data/TribitsExMetaProjRepoVersion.for-testing.txt"
"${CMAKE_CURRENT_LIST_DIR}/data/TribitsExMetaProjRepoVersion.for-testing.with-parents.txt"
BUILD/TribitsExMetaProjRepoVersion.txt
ALWAYS_FAIL_ON_NONZERO_RETURN

Expand Down Expand Up @@ -320,7 +321,7 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re
TEST_12
MESSAGE "Make sure that the file TribitsExMetaProjRepoVersion.txt is correct"
CMND diff ARGS
"${CMAKE_CURRENT_LIST_DIR}/data/TribitsExMetaProjRepoVersion.for-testing.txt"
"${CMAKE_CURRENT_LIST_DIR}/data/TribitsExMetaProjRepoVersion.for-testing.with-parents.txt"
BUILD/TribitsExMetaProjRepoVersion.txt
ALWAYS_FAIL_ON_NONZERO_RETURN

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
*** Base Git Repo: TribitsExMetaProj
863461e [Tue Sep 14 15:05:31 2021 -0600] <[email protected]>
Merge branch 'tribits-github-snapshot' (TriBITSPub/TriBITS#299)
*** Parent 1:
e12aad9 [Fri Dec 11 16:17:18 2020 -0700] <[email protected]>
Merge branch 'tribits-github-snapshot' (TriBITSPub/TriBITS#309)
*** Parent 2:
ed38a1f [Tue Sep 14 15:04:06 2021 -0600] <[email protected]>
Automatic snapshot commit from TribitsExampleMetaProject at d1e4913
*** Git Repo: TribitsExampleProject
94c2b12 [Tue Sep 14 15:18:55 2021 -0600] <[email protected]>
Merge branch 'tribits-github-snapshot' (TriBITSPub/TriBITS#299)
*** Parent 1:
59c7057 [Fri Dec 11 16:23:46 2020 -0700] <[email protected]>
Merge branch 'tribits-github-snapshot'
*** Parent 2:
da4197f [Tue Sep 14 15:11:39 2021 -0600] <[email protected]>
Automatic snapshot commit from TribitsExampleProject at d95ddbd
*** Git Repo: TribitsExampleProjectAddons
d846ae1 [Tue Sep 14 15:23:39 2021 -0600] <[email protected]>
Merge branch 'tribits-github-snapshot' (TriBITSPub/TriBITS#299)
*** Parent 1:
226a17e [Tue Feb 19 06:33:23 2019 -0700] <[email protected]>
Update README file (tribitspub/tribits#278)
*** Parent 2:
08f06bb [Tue Sep 14 15:20:24 2021 -0600] <[email protected]>
Automatic snapshot commit from TribitsExampleProjectAddons at abb6694
55 changes: 26 additions & 29 deletions tribits/core/package_arch/TribitsGlobalMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

# Standard TriBITS system includes

include("${CMAKE_CURRENT_LIST_DIR}/../utils/TribitsGitRepoVersionInfo.cmake")

include("${CMAKE_CURRENT_LIST_DIR}/../common/TribitsConstants.cmake")

include("${CMAKE_CURRENT_LIST_DIR}/../test_support/TribitsTestCategories.cmake")
Expand All @@ -53,7 +55,6 @@ include(TribitsGetVersionDate)
include(TribitsReportInvalidTribitsUsage)
include(TribitsReadAllProjectDepsFilesCreateDepsGraph)
include(TribitsAdjustPackageEnables)
include(TribitsGitRepoVersionInfo)
include(TribitsSetUpEnabledOnlyDependencies)
include(TribitsConfigureTiming)

Expand Down Expand Up @@ -685,6 +686,9 @@ macro(tribits_define_global_options_and_define_extra_repos)
CACHE BOOL
"Generate the ${PROJECT_NAME}RepoVersion.txt file.")

tribits_advanced_set_cache_var_and_default(${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS
BOOL OFF "Show parents' commit info in the repo version output.")

if ("${${PROJECT_NAME}_GENERATE_VERSION_DATE_FILES_DEFAULT}" STREQUAL "")
set(${PROJECT_NAME}_GENERATE_VERSION_DATE_FILES_DEFAULT OFF)
endif()
Expand Down Expand Up @@ -1207,48 +1211,41 @@ endmacro()

# Get the versions of all the git repos
#
function(tribits_generate_repo_version_file_string PROJECT_REPO_VERSION_FILE_STRING_OUT)
function(tribits_generate_repo_version_file_string projectRepoVersionFileStrOut)

set(REPO_VERSION_FILE_STR "")
set(projectRepoVersionFileStr "")

tribits_generate_single_repo_version_string(
${CMAKE_CURRENT_SOURCE_DIR}
SINGLE_REPO_VERSION)
string(APPEND REPO_VERSION_FILE_STR
${CMAKE_CURRENT_SOURCE_DIR} singleRepoVersionStr
INCLUDE_COMMIT_PARENTS ${${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS})
string(APPEND projectRepoVersionFileStr
"*** Base Git Repo: ${PROJECT_NAME}\n"
"${SINGLE_REPO_VERSION}\n" )
"${singleRepoVersionStr}\n" )

set(EXTRAREPO_IDX 0)
foreach(EXTRA_REPO ${${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES})

#print_var(EXTRA_REPO)
#print_var(EXTRAREPO_IDX)
#print_var(${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES_DIRS)
set(extraRepoIdx 0)
foreach(extraRepo ${${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES})

if (${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES_DIRS)
# Read from an extra repo file with potentially different dir.
list(GET ${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES_DIRS ${EXTRAREPO_IDX}
EXTRAREPO_DIR )
list(GET ${PROJECT_NAME}_ALL_EXTRA_REPOSITORIES_DIRS ${extraRepoIdx}
extraRepoDir )
else()
# Not read from extra repo file so dir is same as name
set(EXTRAREPO_DIR ${EXTRA_REPO})
set(extraRepoDir ${extraRepo})
endif()
#print_var(EXTRAREPO_DIR)

tribits_generate_single_repo_version_string(
"${CMAKE_CURRENT_SOURCE_DIR}/${EXTRAREPO_DIR}"
SINGLE_REPO_VERSION)
string(APPEND REPO_VERSION_FILE_STR
"*** Git Repo: ${EXTRAREPO_DIR}\n"
"${SINGLE_REPO_VERSION}\n" )

#print_var(REPO_VERSION_FILE_STR)
"${CMAKE_CURRENT_SOURCE_DIR}/${extraRepoDir}" singleRepoVersionStr
INCLUDE_COMMIT_PARENTS ${${PROJECT_NAME}_SHOW_GIT_COMMIT_PARENTS})
string(APPEND projectRepoVersionFileStr
"*** Git Repo: ${extraRepoDir}\n"
"${singleRepoVersionStr}\n" )

math(EXPR EXTRAREPO_IDX "${EXTRAREPO_IDX}+1")
math(EXPR extraRepoIdx "${extraRepoIdx}+1")

endforeach()

set(${PROJECT_REPO_VERSION_FILE_STRING_OUT} ${REPO_VERSION_FILE_STR} PARENT_SCOPE)
set(${projectRepoVersionFileStrOut} ${projectRepoVersionFileStr} PARENT_SCOPE)

endfunction()

Expand All @@ -1260,17 +1257,17 @@ endfunction()
#
function(tribits_generate_repo_version_output_and_file)
# Get the repos versions
tribits_generate_repo_version_file_string(PROJECT_REPO_VERSION_FILE_STRING)
tribits_generate_repo_version_file_string(projectRepoVersionFileStr)
# Print the versions
message("\n${PROJECT_NAME} repos versions:\n"
"--------------------------------------------------------------------------------\n"
"${PROJECT_REPO_VERSION_FILE_STRING}"
"${projectRepoVersionFileStr}"
" --------------------------------------------------------------------------------\n"
)
#) Write out the version file
file(WRITE
"${CMAKE_CURRENT_BINARY_DIR}/${${PROJECT_NAME}_REPO_VERSION_FILE_NAME}"
"${PROJECT_REPO_VERSION_FILE_STRING}")
"${projectRepoVersionFileStr}")
endfunction()


Expand Down
Loading
Loading