Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use get allsky branch() #2785

Merged
merged 8 commits into from
Jun 14, 2023
8 changes: 4 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ stop_allsky()
# Get the branch of the release we are installing;
get_this_branch()
{
if ! B="$( get_allsky_branch "${ALLSKY_HOME}" )" ; then
if ! B="$( get_branch )" ; then
display_msg --log warning "Unable to determine branch; assuming '${BRANCH}'."
else
BRANCH="${B}"
Expand Down Expand Up @@ -1015,8 +1015,8 @@ handle_prior_website()
fi
fi

# Trailing "/" tells get_version and get_branch to fill in the file
# names given the directory we pass to them.
# Trailing "/" tells get_version to fill in the file
# name given the directory we pass to them.

# If there's no prior website version, then there IS a newer version available.
# Set ${PV} to a string to display in messages, but we'll still use ${PRIOR_VERSION}
Expand Down Expand Up @@ -1044,7 +1044,7 @@ handle_prior_website()
if [[ ${PRIOR_STYLE} == "new" ]]; then

# If get_branch returns "" the prior branch is ${GITHUB_MAIN_BRANCH}.
local PRIOR_BRANCH="$( get_branch "${PRIOR_SITE}/" )"
local PRIOR_BRANCH="$( get_branch "${PRIOR_SITE}" )"

display_msg --log progress "Restoring local Allsky Website from ${PRIOR_SITE}."
sudo mv "${PRIOR_SITE}" "${ALLSKY_WEBSITE}"
Expand Down
3 changes: 1 addition & 2 deletions scripts/check_allsky.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ source "${ALLSKY_CONFIG}/config.sh" || exit ${ALLSKY_ERROR_STOP}
source "${ALLSKY_CONFIG}/ftp-settings.sh" || exit ${ALLSKY_ERROR_STOP}
PROTOCOL="${PROTOCOL,,}" # set to lowercase to make comparing easier

BRANCH="$( get_allsky_branch "${ALLSKY_HOME}" )"
BRANCH="$( get_branch "" )"
[[ -z ${BRANCH} ]] && BRANCH="${GITHUB_MAIN_BRANCH}"
[[ ${DEBUG} == "true" ]] && echo "DEBUG: using '${BRANCH}' branch."

Expand Down Expand Up @@ -811,4 +811,3 @@ else
fi

exit ${RET}

23 changes: 5 additions & 18 deletions scripts/installUpgradeFunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ function get_Git_version() {
}


# For the version and branch, if the last character of the argument passed is a "/",
# then append the file name from ${ALLSKY_VERSION_FILE} or ${ALLSKY_BRANCH_FILE}.
# We do this to limit the number of places that know the actual name of the files,
# in case we ever change their names.
# For the version, if the last character of the argument passed is a "/",
# then append the file name from ${ALLSKY_VERSION_FILE}.
# We do this to limit the number of places that know the actual name of the file,
# in case we ever change it.

#####
# Get the version from a local file, if it exists.
Expand All @@ -67,24 +67,11 @@ function get_version() {

#####
# Get the branch using git.
function get_allsky_branch() {
function get_branch() {
local H="${1:-${ALLSKY_HOME}}"
echo "$( cd "${H}" || exit; git rev-parse --abbrev-ref HEAD )"
}

#####
# Get the branch from a local file, if it exists.
function get_branch() {
local F="${1}"
if [[ -z ${F} ]]; then
F="${ALLSKY_BRANCH_FILE}" # default
else
[[ ${F:1,-1} == "/" ]] && F="${F}$(basename "${ALLSKY_BRANCH_FILE}")"
fi

# Branch file is same format as Version file.
echo -n "$(get_version "${F}")"
}

#####
# Display a message of various types in appropriate colors.
Expand Down
2 changes: 1 addition & 1 deletion upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ done

[[ ${DEBUG} == "true" ]] && echo "Running: ${ME} ${ALL_ARGS}"

BRANCH="$( get_branch "${ALLSKY_BRANCH_FILE}" )"
BRANCH="$( get_branch )"
[[ -z ${BRANCH} ]] && BRANCH="${GITHUB_MAIN_BRANCH}"

# Unless forced to, only do the version check if we're on the main branch,
Expand Down
3 changes: 1 addition & 2 deletions variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ if [[ -z "${ALLSKY_VARIABLE_SET}" ]]; then
ALLSKY_FLOWTIMINGS_DAY="${ALLSKY_FLOWTIMINGS}/day-average"
ALLSKY_FLOWTIMINGS_NIGHT="${ALLSKY_FLOWTIMINGS}/night-average"

# Verion file and option branch file.
# Verion file.
ALLSKY_VERSION_FILE="${ALLSKY_HOME}/version"
ALLSKY_BRANCH_FILE="${ALLSKY_HOME}/branch"

# Location of optional allsky-website package.
ALLSKY_WEBSITE="${ALLSKY_WEBUI}/allsky"
Expand Down
2 changes: 1 addition & 1 deletion website/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ get_versions_and_branches()
fi

if [[ ${PRIOR_WEBSITE_TYPE} == "new" ]]; then
PRIOR_WEBSITE_BRANCH="$( get_branch "${PRIOR_WEBSITE}/" )"
PRIOR_WEBSITE_BRANCH="$( get_branch "${PRIOR_WEBSITE}" )"
fi
PRIOR_WEBSITE_BRANCH="${PRIOR_WEBSITE_BRANCH:-${GITHUB_MAIN_BRANCH}}"

Expand Down