Skip to content

Commit 7fdd44f

Browse files
authored
Merge pull request #4526 from AllskyTeam/Handle-branch-of-"HEAD"
Update installUpgradeFunctions.sh: Check for BRANCH == HEAD
2 parents 692fa3d + cf15036 commit 7fdd44f

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

scripts/installUpgradeFunctions.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,18 @@ function get_version()
123123
function get_branch()
124124
{
125125
local H="${1:-${ALLSKY_HOME}}"
126-
echo "$( cd "${H}" || exit; git rev-parse --abbrev-ref HEAD )"
126+
local BRANCH="$( cd "${H}" || exit; git rev-parse --abbrev-ref HEAD )"
127+
if [[ ${BRANCH} == "HEAD" ]]; then
128+
# If the user is getting the master branch but uses the "--branch master_branch_name",
129+
# BRANCH will be "HEAD". For example if the master branch is v2024.12.06_02 and the user
130+
# runs "git clone --branch v2024.12.06_02 ...".
131+
local FILE="${H}/.git/packed-refs"
132+
if [[ -s ${FILE} ]]; then
133+
local B="$( tail -1 "${FILE}" | sed -e 's;.*/;;' )"
134+
[[ -n ${B} ]] && BRANCH="${B}"
135+
fi
136+
fi
137+
echo "${BRANCH}"
127138
}
128139

129140

0 commit comments

Comments
 (0)