Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
54227596c2
|
|||
f480b6f1f3
|
|||
052353765d
|
@ -3,7 +3,7 @@
|
|||||||
# Program name
|
# Program name
|
||||||
PROGRAM_NAME="Octojpack"
|
PROGRAM_NAME="Octojpack"
|
||||||
PROGRAM_CODE="octojpack"
|
PROGRAM_CODE="octojpack"
|
||||||
PROGRAM_VERSION="1.3.5"
|
PROGRAM_VERSION="1.3.8"
|
||||||
PROGRAM_V="1.3"
|
PROGRAM_V="1.3"
|
||||||
PROGRAM_URL="https://git.vdm.dev/octoleo/${PROGRAM_CODE}"
|
PROGRAM_URL="https://git.vdm.dev/octoleo/${PROGRAM_CODE}"
|
||||||
|
|
||||||
@ -995,7 +995,7 @@ function setRepository() {
|
|||||||
# check if the repository exist on our gitea instance
|
# check if the repository exist on our gitea instance
|
||||||
local update_repo
|
local update_repo
|
||||||
# shellcheck disable=SC2015
|
# shellcheck disable=SC2015
|
||||||
if git ls-remote "git@${VDM_PACKAGE_URL}/${VDM_PACKAGE_OWNER}/${VDM_PACKAGE_REPO}.git" -q >/dev/null 2>&1; then
|
if git ls-remote --exit-code --heads "git@${VDM_PACKAGE_URL}:${VDM_PACKAGE_OWNER}/${VDM_PACKAGE_REPO}.git" >/dev/null 2>&1; then
|
||||||
getExistingRepository || return 23
|
getExistingRepository || return 23
|
||||||
update_repo=true
|
update_repo=true
|
||||||
else
|
else
|
||||||
@ -1009,11 +1009,11 @@ function setRepository() {
|
|||||||
# move all new files into repository
|
# move all new files into repository
|
||||||
setRepositoryNewFiles || return 27
|
setRepositoryNewFiles || return 27
|
||||||
# check if we have changes
|
# check if we have changes
|
||||||
if $update_repo && [[ -z $(git status --porcelain) ]]; then
|
if [[ "${update_repo}" == true && -z $(git status --porcelain) ]]; then
|
||||||
_echo "[info] No changes found in (${VDM_PACKAGE_OWNER}/${VDM_PACKAGE_REPO}) repository"
|
_echo "[info] No changes found in (${VDM_PACKAGE_OWNER}/${VDM_PACKAGE_REPO}) repository"
|
||||||
else
|
else
|
||||||
# check if we must update or create repository
|
# check if we must update or create repository
|
||||||
if $update_repo; then
|
if [[ "${update_repo}" == true ]]; then
|
||||||
# make API call
|
# make API call
|
||||||
callGiteaAPI "tags" "${VDM_PACKAGE_OWNER}" "${VDM_PACKAGE_REPO}" "${VDM_PACKAGE_API}" "${VDM_PACKAGE_TOKEN}" || return 28
|
callGiteaAPI "tags" "${VDM_PACKAGE_OWNER}" "${VDM_PACKAGE_REPO}" "${VDM_PACKAGE_API}" "${VDM_PACKAGE_TOKEN}" || return 28
|
||||||
# check if tag exists
|
# check if tag exists
|
||||||
@ -1059,10 +1059,10 @@ function getExistingRepository() {
|
|||||||
_echo "[info] Getting (${VDM_PACKAGE_OWNER}/${VDM_PACKAGE_REPO}) repository"
|
_echo "[info] Getting (${VDM_PACKAGE_OWNER}/${VDM_PACKAGE_REPO}) repository"
|
||||||
if [[ "${VDM_PACKAGE_REPO_BRANCH}" == 'default' ]]; then
|
if [[ "${VDM_PACKAGE_REPO_BRANCH}" == 'default' ]]; then
|
||||||
# clone the existing repository
|
# clone the existing repository
|
||||||
git clone "git@${VDM_PACKAGE_URL}/${VDM_PACKAGE_OWNER}/${VDM_PACKAGE_REPO}.git" >/dev/null 2>&1 || return 23
|
git clone "git@${VDM_PACKAGE_URL}:${VDM_PACKAGE_OWNER}/${VDM_PACKAGE_REPO}.git" >/dev/null 2>&1 || return 23
|
||||||
else
|
else
|
||||||
# clone the existing repository
|
# clone the existing repository
|
||||||
git clone -b "${VDM_PACKAGE_REPO_BRANCH:-master}" "git@${VDM_PACKAGE_URL}/${VDM_PACKAGE_OWNER}/${VDM_PACKAGE_REPO}.git" >/dev/null 2>&1 || return 23
|
git clone -b "${VDM_PACKAGE_REPO_BRANCH:-master}" "git@${VDM_PACKAGE_URL}:${VDM_PACKAGE_OWNER}/${VDM_PACKAGE_REPO}.git" >/dev/null 2>&1 || return 23
|
||||||
fi
|
fi
|
||||||
# success
|
# success
|
||||||
return 0
|
return 0
|
||||||
@ -1091,7 +1091,7 @@ function setGitRepository() {
|
|||||||
# little information of progress
|
# little information of progress
|
||||||
_echo "[info] Adding remote branch to (${VDM_PACKAGE_OWNER}/${VDM_PACKAGE_REPO}) repository"
|
_echo "[info] Adding remote branch to (${VDM_PACKAGE_OWNER}/${VDM_PACKAGE_REPO}) repository"
|
||||||
# add the remote branch
|
# add the remote branch
|
||||||
git remote add origin "git@${VDM_PACKAGE_URL}/${VDM_PACKAGE_OWNER}/${VDM_PACKAGE_REPO}.git" >/dev/null 2>&1 || return 29
|
git remote add origin "git@${VDM_PACKAGE_URL}:${VDM_PACKAGE_OWNER}/${VDM_PACKAGE_REPO}.git" >/dev/null 2>&1 || return 29
|
||||||
# Check if a specific branch is set and it is not 'default'
|
# Check if a specific branch is set and it is not 'default'
|
||||||
if [ "${VDM_PACKAGE_REPO_BRANCH}" != "default" ]; then
|
if [ "${VDM_PACKAGE_REPO_BRANCH}" != "default" ]; then
|
||||||
_echo "[info] Setting branch to ${VDM_PACKAGE_REPO_BRANCH}"
|
_echo "[info] Setting branch to ${VDM_PACKAGE_REPO_BRANCH}"
|
||||||
@ -1181,7 +1181,7 @@ function getUniqueFileName() {
|
|||||||
echo "${hash:0:10}"
|
echo "${hash:0:10}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# get the version from the current directory
|
# Get the version from the current directory
|
||||||
function _xml_version() {
|
function _xml_version() {
|
||||||
local version=""
|
local version=""
|
||||||
local shortest_depth=100
|
local shortest_depth=100
|
||||||
@ -1196,22 +1196,31 @@ function _xml_version() {
|
|||||||
*config.xml|*access.xml|*default.xml) continue ;;
|
*config.xml|*access.xml|*default.xml) continue ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Ensure it's an extension XML and not an update XML
|
# Ensure it's an extension XML (check if it has a <extension> root tag anywhere)
|
||||||
grep -q '<extension' "$file" || continue
|
if ! grep -iq '^[[:space:]]*<extension[[:space:]>]' "$file"; then
|
||||||
|
continue
|
||||||
# Extract version if present in XML
|
|
||||||
v=$(sed -n 's|.*<version>\([^<]*\)</version>.*|\1|p' "$file")
|
|
||||||
|
|
||||||
# Determine folder depth (count slashes)
|
|
||||||
depth=$(awk -F'/' '{print NF}' <<< "$file")
|
|
||||||
|
|
||||||
# Choose the file with the shortest path (highest in folder stack)
|
|
||||||
if [[ -n "$v" && "$depth" -lt "$shortest_depth" ]]; then
|
|
||||||
shortest_depth="$depth"
|
|
||||||
version="$v"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done < <(find . -type f -name '*.xml')
|
# Extract version if present in XML
|
||||||
|
v=$(sed -n 's|.*<version>\(.*\)</version>.*|\1|p' "$file" | head -n1)
|
||||||
|
|
||||||
|
# Skip if no version found
|
||||||
|
[[ -z "$v" ]] && continue
|
||||||
|
|
||||||
|
# Determine folder depth (count slashes)
|
||||||
|
depth=$(tr -cd '/' <<< "$file" | wc -c)
|
||||||
|
|
||||||
|
# Choose the file with the shortest path (highest in folder stack)
|
||||||
|
if (( depth < shortest_depth )); then
|
||||||
|
shortest_depth=$depth
|
||||||
|
version=$v
|
||||||
|
|
||||||
|
# Since we want the highest-up file, and this is the shallowest so far,
|
||||||
|
# we can break early if it's at root level (depth 1)
|
||||||
|
(( depth <= 1 )) && break
|
||||||
|
fi
|
||||||
|
|
||||||
|
done < <(find . -type f -iname '*.xml')
|
||||||
|
|
||||||
# Return failure if no version is found
|
# Return failure if no version is found
|
||||||
if [[ -z "$version" ]]; then
|
if [[ -z "$version" ]]; then
|
||||||
|
Reference in New Issue
Block a user