armbian-next: git/ref2info: fixes for using commit:<sha1>

This commit is contained in:
Ricardo Pardini
2023-02-07 15:13:30 +01:00
parent 843449597a
commit 85d13cf8ce
2 changed files with 15 additions and 6 deletions

View File

@@ -26,8 +26,16 @@ function memoized_git_ref_to_info() {
# Get the SHA1 of the commit
declare sha1
display_alert "Fetching SHA1 of ${ref_type} ${ref_name}" "${MEMO_DICT[GIT_SOURCE]}" "info"
sha1="$(git ls-remote --exit-code "${MEMO_DICT[GIT_SOURCE]}" "${ref_name}" | cut -f1)"
display_alert "SHA1 of ${ref_type} ${ref_name}" "${sha1}" "info"
case "${ref_type}" in
commit)
sha1="${ref_name}"
;;
*)
sha1="$(git ls-remote --exit-code "${MEMO_DICT[GIT_SOURCE]}" "${ref_name}" | cut -f1)"
;;
esac
display_alert "SHA1 of ${ref_type} ${ref_name}" "'${sha1}'" "info"
MEMO_DICT+=(["SHA1"]="${sha1}")
if [[ "${2}" == "include_makefile_body" ]]; then

View File

@@ -164,18 +164,19 @@ function fetch_from_repo() {
local local_hash
local_hash=$(git rev-parse @ 2> /dev/null || true) # Don't fail nor output anything if failure
# remote hash; will be calculated depending on ref_type below
local remote_hash
# when we work offline we simply return the sources to their original state
if ! $offline; then
case $ref_type in
branch)
# TODO: grep refs/heads/$name
local remote_hash
remote_hash=$(git ls-remote -h "${url}" "$ref_name" | head -1 | cut -f1)
[[ -z $local_hash || "${local_hash}" != "a${remote_hash}" ]] && changed=true
;;
tag)
local remote_hash
remote_hash=$(git ls-remote -t "${url}" "$ref_name" | cut -f1)
if [[ -z $local_hash || "${local_hash}" != "${remote_hash}" ]]; then
remote_hash=$(git ls-remote -t "${url}" "$ref_name^{}" | cut -f1)
@@ -183,12 +184,12 @@ function fetch_from_repo() {
fi
;;
head)
local remote_hash
remote_hash=$(git ls-remote "${url}" HEAD | cut -f1)
[[ -z $local_hash || "${local_hash}" != "${remote_hash}" ]] && changed=true
;;
commit)
[[ -z $local_hash || $local_hash == "@" ]] && changed=true
remote_hash="${ref_name}"
[[ -z $local_hash || $local_hash == "@" || "${local_hash}" != "${remote_hash}" ]] && changed=true
;;
esac