Skip to content

Commit

Permalink
Updated tribits_gernerate_single_repo_version_string to use HEAD (#597)
Browse files Browse the repository at this point in the history
Instead of passing in the deferenced HEAD SHA1 to tribites_generate_commit_info_string,
simply just pass in the HEAD pointer keyword for Git to deference itself.
  • Loading branch information
achauphan committed Jan 16, 2024
1 parent 592ea0d commit e4b19b6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%H
MOCK_PROGRAM_RETURN: 0
MOCK_PROGRAM_OUTPUT: a1234tgbhyujkliu126sl12123s
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%h [%ad] <%ae> a1234tgbhyujkliu126sl12123s
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 a1234tgbhyujkliu126sl12123s
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 a1234tgbhyujkliu126sl12123s
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
@@ -1,13 +1,10 @@
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%H
MOCK_PROGRAM_RETURN: 0
MOCK_PROGRAM_OUTPUT: a1234tgbhyujkliu126sl12123s
MOCK_PROGRAM_INPUT: log -1 --pretty=format:%h [%ad] <%ae> a1234tgbhyujkliu126sl12123s
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 a1234tgbhyujkliu126sl12123s
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 a1234tgbhyujkliu126sl12123s
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
Expand Down
9 changes: 2 additions & 7 deletions tribits/core/package_arch/TribitsGitRepoVersionInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,14 @@ function(tribits_generate_single_repo_version_string gitRepoDir

# A) Get HEAD commit's info

tribits_git_repo_sha1(${gitRepoDir}
gitHeadSha1)

tribits_generate_commit_info_string(
${gitRepoDir} ${gitHeadSha1}
commitInfoString)
tribits_generate_commit_info_string(${gitRepoDir} HEAD commitInfoString)

set(outStringBuilder ${commitInfoString})

# B) Get all of HEAD commit's parents into a list

execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 "--pretty=format:%p" ${gitHeadSha1}
COMMAND ${GIT_EXECUTABLE} log -1 "--pretty=format:%p" HEAD
WORKING_DIRECTORY ${gitRepoDir}
RESULT_VARIABLE gitCmndRtn OUTPUT_VARIABLE gitCmndOutput
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE
Expand Down

0 comments on commit e4b19b6

Please sign in to comment.