git/docker: bsp-cli: fix BUILD_REPOSITORY_URL and BUILD_REPOSITORY_COMMIT under Docker; fixes AR-1750

This commit is contained in:
Ricardo Pardini
2023-05-24 16:32:31 +02:00
committed by igorpecovnik
parent 03810833ef
commit 52710b3363
4 changed files with 33 additions and 3 deletions

View File

@@ -70,9 +70,10 @@ function do_main_configuration() {
[[ -z "${CHROOT_CACHE_VERSION}" ]] && CHROOT_CACHE_VERSION=7
if [[ -d "${SRC}/.git" && "${CONFIG_DEFS_ONLY}" != "yes" ]]; then # don't waste time if only gathering config defs
display_alert "Getting git info for repo" "${SRC}" "debug"
BUILD_REPOSITORY_URL="$(git remote get-url "$(git remote | grep origin || true)" || true)" # ignore all errors
BUILD_REPOSITORY_COMMIT="$(git describe --match=d_e_a_d_b_e_e_f --always --dirty || true)" # ignore error
# The docker launcher will have passed these as environment variables. If not, try again here.
if [[ -z "${BUILD_REPOSITORY_URL}" || -z "${BUILD_REPOSITORY_COMMIT}" ]]; then
set_git_build_repo_url_and_commit_vars "main configuration"
fi
fi
ROOTFS_CACHE_MAX=200 # max number of rootfs cache, older ones will be cleaned up
@@ -500,3 +501,13 @@ function source_family_config_and_arch() {
return 0
}
function set_git_build_repo_url_and_commit_vars() {
display_alert "Getting git info for repo, during ${1}..." "${SRC}" "debug"
declare -g BUILD_REPOSITORY_URL BUILD_REPOSITORY_COMMIT
BUILD_REPOSITORY_URL="$(git -C "${SRC}" remote get-url "$(git -C "${SRC}" remote | grep origin || true)" || true)" # ignore all errors
BUILD_REPOSITORY_COMMIT="$(git -C "${SRC}" describe --match=d_e_a_d_b_e_e_f --always --dirty || true)" # ignore error
display_alert "BUILD_REPOSITORY_URL set during ${1}" "${BUILD_REPOSITORY_URL}" "debug"
display_alert "BUILD_REPOSITORY_COMMIT set during ${1}" "${BUILD_REPOSITORY_COMMIT}" "debug"
return 0
}