Skip to content

Commit

Permalink
Add starts with check for dependency sha1 hashes, previously did stri…
Browse files Browse the repository at this point in the history
…ct equals
  • Loading branch information
Cliff Foster committed Mar 11, 2024
1 parent 16d8414 commit e387789
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions cmake/idi/functions/idi_add_dependency.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ function(idi_get_repo_information REPO_DIR)
)
endfunction()

function(idi_commit_starts_with ACTUAL_SHA1 CHECK_SHA1)
set(IDI_REPO_SHA1_SAME false)
string(FIND "${ACTUAL_SHA1}" "${CHECK_SHA1}" IDI_STARTS_WITH_SHA1)
if("${IDI_STARTS_WITH_SHA1}" EQUAL 0)
set(IDI_REPO_SHA1_SAME true)
endif()
return(PROPAGATE IDI_REPO_SHA1_SAME)
endfunction()

function(__idi_add_dependency IDI_DEP_NAME IDI_DEP_URL IDI_DEP_TAG IDI_DEP_THIRD_PARTY)
set(options DOWNLOAD_ONLY)
set(multiValueArgs DEP_OPTIONS)
Expand All @@ -95,6 +104,7 @@ function(__idi_add_dependency IDI_DEP_NAME IDI_DEP_URL IDI_DEP_TAG IDI_DEP_THIRD

idi_get_repo_information(${IDI_DEP_SOURCE_DIR})

message("${IDI_DEP_NAME} IDI_DEP_TAG: ${IDI_DEP_TAG}")
message("${IDI_DEP_NAME} IDI_REPO_IS_PORCELAIN: ${IDI_REPO_IS_PORCELAIN}")
message("${IDI_DEP_NAME} IDI_REPO_TAG: ${IDI_REPO_TAG}")
message("${IDI_DEP_NAME} IDI_REPO_SHA1: ${IDI_REPO_SHA1}")
Expand All @@ -104,9 +114,11 @@ function(__idi_add_dependency IDI_DEP_NAME IDI_DEP_URL IDI_DEP_TAG IDI_DEP_THIRD
message(WARNING "Third-party dependency '${IDI_DEP_NAME}' has uncomitted or untracked files.")
endif()

idi_commit_starts_with("${IDI_REPO_SHA1}" "${IDI_DEP_TAG}")

if (
(NOT ("${IDI_REPO_TAG}" STREQUAL "${IDI_DEP_TAG}")) AND
(NOT ("${IDI_REPO_SHA1}" STREQUAL "${IDI_DEP_TAG}")) AND
(NOT IDI_REPO_SHA1_SAME) AND
(NOT ("${IDI_REPO_BRANCH}" STREQUAL "${IDI_DEP_TAG}"))
)
set(IDI_DO_POPULATE true)
Expand All @@ -122,6 +134,7 @@ function(__idi_add_dependency IDI_DEP_NAME IDI_DEP_URL IDI_DEP_TAG IDI_DEP_THIRD

idi_get_repo_information(${IDI_DEP_SOURCE_DIR})

message("${IDI_DEP_NAME} IDI_DEP_TAG: ${IDI_DEP_TAG}")
message("${IDI_DEP_NAME} IDI_REPO_IS_PORCELAIN: ${IDI_REPO_IS_PORCELAIN}")
message("${IDI_DEP_NAME} IDI_REPO_TAG: ${IDI_REPO_TAG}")
message("${IDI_DEP_NAME} IDI_REPO_SHA1: ${IDI_REPO_SHA1}")
Expand All @@ -132,11 +145,13 @@ function(__idi_add_dependency IDI_DEP_NAME IDI_DEP_URL IDI_DEP_TAG IDI_DEP_THIRD
message(WARNING "First-party dependency '${IDI_DEP_NAME}' has uncomitted or untracked files.")
endif()

idi_commit_starts_with("${IDI_REPO_SHA1}" "${IDI_DEP_TAG}")

set(IDI_REPO_SAME_COMMIT true)

if (
(NOT ("${IDI_REPO_TAG}" STREQUAL "${IDI_DEP_TAG}")) AND
(NOT ("${IDI_REPO_SHA1}" STREQUAL "${IDI_DEP_TAG}")) AND
(NOT IDI_REPO_SHA1_SAME) AND
(NOT ("${IDI_REPO_BRANCH}" STREQUAL "${IDI_DEP_TAG}"))
)
message(WARNING "First-party dependency '${IDI_DEP_NAME}' is not on the same commit as defined by configuration. ${IDI_DEP_TAG} != ${IDI_REPO_TAG}|${IDI_REPO_SHA1}|${IDI_REPO_BRANCH}")
Expand Down

0 comments on commit e387789

Please sign in to comment.