Fixed some AI introduced bugs.
This commit is contained in:
parent
1cd39a8480
commit
7e872210f9
54
src/octozipo
54
src/octozipo
@ -188,23 +188,22 @@ setNewRepository() {
|
|||||||
setExistingRepository() {
|
setExistingRepository() {
|
||||||
# Notifies the user that the existing repository is being updated.
|
# Notifies the user that the existing repository is being updated.
|
||||||
_echo "[info] Update ($VDM_REPO_NAME) existing repository"
|
_echo "[info] Update ($VDM_REPO_NAME) existing repository"
|
||||||
|
|
||||||
# Checks if there are any changes in the repository.
|
# Checks if there are any changes in the repository.
|
||||||
if [[ -z $(git status --porcelain) ]]; then
|
if [[ -z $(git status --porcelain) ]]; then # ALTERNATIVE: if git diff-index --quiet HEAD --; then
|
||||||
# If there are no changes, inform the user.
|
|
||||||
_echo "[info] No changes found in ($VDM_REPO_NAME v$VDM_VERSION) repository"
|
_echo "[info] No changes found in ($VDM_REPO_NAME v$VDM_VERSION) repository"
|
||||||
else
|
else
|
||||||
|
|
||||||
# set repository user details
|
# set repository user details
|
||||||
setUserDetails
|
setUserDetails
|
||||||
|
|
||||||
# If there are changes, create a commit message.
|
# If there are changes, create a commit message.
|
||||||
commit_msg="update"
|
if [ "$(git tag -l "v$VDM_VERSION")" ]; then
|
||||||
if ! [ "$(git tag -l "v$VDM_VERSION")" ]; then
|
setGitCommit "$VDM_VERSION" "update" || return 4
|
||||||
commit_msg="$commit_msg - v$VDM_VERSION"
|
else
|
||||||
|
setGitCommit "$VDM_VERSION" "update - v$VDM_VERSION" || return 4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Creates a commit with the message and returns an error code of 4 if unsuccessful.
|
|
||||||
setGitCommit "$VDM_VERSION" "$commit_msg" || return 4
|
|
||||||
|
|
||||||
# Pushes the changes and returns an error code of 1 if unsuccessful.
|
# Pushes the changes and returns an error code of 1 if unsuccessful.
|
||||||
setPushChanges || return 1
|
setPushChanges || return 1
|
||||||
|
|
||||||
@ -271,9 +270,8 @@ setNewFiles() {
|
|||||||
# 4 - if an error occurs during the creation of a commit
|
# 4 - if an error occurs during the creation of a commit
|
||||||
setGitInit() {
|
setGitInit() {
|
||||||
# Checks if the current directory is a Git repository.
|
# Checks if the current directory is a Git repository.
|
||||||
if git rev-parse --git-dir > /dev/null 2>&1; then
|
if [ -d ".git" ]; then
|
||||||
# If it is, checks if there are any changes in the repository.
|
if [[ -z $(git status --porcelain) ]]; then # ALTERNATIVE: if git diff-index --quiet HEAD --; then
|
||||||
if git diff-index --quiet HEAD --; then
|
|
||||||
# If there are no changes, inform the user.
|
# If there are no changes, inform the user.
|
||||||
_echo "[info] No changes found in repository"
|
_echo "[info] No changes found in repository"
|
||||||
else
|
else
|
||||||
@ -295,6 +293,9 @@ setGitInit() {
|
|||||||
# If the current directory is not a Git repository, initialize it.
|
# If the current directory is not a Git repository, initialize it.
|
||||||
git init >/dev/null 2>&1 || return 4
|
git init >/dev/null 2>&1 || return 4
|
||||||
|
|
||||||
|
# set repository user details
|
||||||
|
setUserDetails
|
||||||
|
|
||||||
# Check if there is a version number.
|
# Check if there is a version number.
|
||||||
if [ -z "$VDM_VERSION" ]; then
|
if [ -z "$VDM_VERSION" ]; then
|
||||||
# If there is no version number, create a commit with the "first commit" message.
|
# If there is no version number, create a commit with the "first commit" message.
|
||||||
@ -329,7 +330,7 @@ setGitInit() {
|
|||||||
#
|
#
|
||||||
# Returns:
|
# Returns:
|
||||||
# None
|
# None
|
||||||
setUserDetails () {
|
function setUserDetails () {
|
||||||
# Set Git author name
|
# Set Git author name
|
||||||
if [ -n "${GIT_AUTHOR_NAME+x}" ]; then
|
if [ -n "${GIT_AUTHOR_NAME+x}" ]; then
|
||||||
git config user.name "${GIT_AUTHOR_NAME}"
|
git config user.name "${GIT_AUTHOR_NAME}"
|
||||||
@ -378,21 +379,18 @@ setGitCommit() {
|
|||||||
git add . >/dev/null 2>&1 || return 1
|
git add . >/dev/null 2>&1 || return 1
|
||||||
|
|
||||||
# Makes a Git commit with the specified commit message.
|
# Makes a Git commit with the specified commit message.
|
||||||
if ! git commit -am"$2" >/dev/null 2>&1; then
|
git commit -am"$2" >/dev/null 2>&1 || return 1
|
||||||
# Return an error code of 1 if the commit was unsuccessful.
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If a version number is provided, create a new Git tag for the commit.
|
# If a version number is provided, create a new Git tag for the commit.
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
# Check if the tag already exists.
|
# Check if the tag already exists.
|
||||||
if ! git tag -l "v$1" >/dev/null 2>&1; then
|
if [ "$(git tag -l "v$1")" ]; then
|
||||||
|
# Return 0 if the function has completed successfully.
|
||||||
|
return 0
|
||||||
|
else
|
||||||
# If the tag does not exist, create it.
|
# If the tag does not exist, create it.
|
||||||
if ! git tag "v$1" >/dev/null 2>&1; then
|
# Return an error code of 1 if the tag creation was unsuccessful.
|
||||||
# Return an error code of 1 if the tag creation was unsuccessful.
|
git tag "v$1" >/dev/null 2>&1 || return 1
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Notify the user that the tag was added.
|
# Notify the user that the tag was added.
|
||||||
_echo "[info] Added v$1 tag"
|
_echo "[info] Added v$1 tag"
|
||||||
fi
|
fi
|
||||||
@ -483,7 +481,8 @@ getPackageDetails() {
|
|||||||
find . -type f -name '*.xml' > tmp
|
find . -type f -name '*.xml' > tmp
|
||||||
|
|
||||||
# Loop through the list of XML files.
|
# Loop through the list of XML files.
|
||||||
while IFS= read -r file; do
|
while IFS= read -r file
|
||||||
|
do
|
||||||
# Skip XML files named config.xml, access.xml, or default.xml.
|
# Skip XML files named config.xml, access.xml, or default.xml.
|
||||||
if [[ "$file" == *"config.xml" ]] || [[ "$file" == *"access.xml" ]] || [[ "$file" == *"default.xml" ]]; then
|
if [[ "$file" == *"config.xml" ]] || [[ "$file" == *"access.xml" ]] || [[ "$file" == *"default.xml" ]]; then
|
||||||
continue
|
continue
|
||||||
@ -526,7 +525,7 @@ getPackageDetails() {
|
|||||||
unset e
|
unset e
|
||||||
done < tmp
|
done < tmp
|
||||||
|
|
||||||
# Remove the tmp file.
|
# Clear variables for each loop.
|
||||||
rm tmp
|
rm tmp
|
||||||
|
|
||||||
# Set the path of the repository for the package.
|
# Set the path of the repository for the package.
|
||||||
@ -550,8 +549,8 @@ getPackageDetails() {
|
|||||||
|
|
||||||
# Check if an environment file exists for the package.
|
# Check if an environment file exists for the package.
|
||||||
env_file="${VDM_ZIP_DIR}/${folder_name}/.${PROGRAM_CODE}"
|
env_file="${VDM_ZIP_DIR}/${folder_name}/.${PROGRAM_CODE}"
|
||||||
|
# If the environment file exists, get the repository name from the file.
|
||||||
if [ -f "${env_file}" ]; then
|
if [ -f "${env_file}" ]; then
|
||||||
# If the environment file exists, get the repository name from the file.
|
|
||||||
env_name=$( grep "repo_name=" "${env_file}" | cut -d'=' -f2)
|
env_name=$( grep "repo_name=" "${env_file}" | cut -d'=' -f2)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -717,7 +716,7 @@ function getVersionNumberByFile() {
|
|||||||
# The modified string.
|
# The modified string.
|
||||||
|
|
||||||
function rightStrip() {
|
function rightStrip() {
|
||||||
# Trim the specified pattern from the end of the string.
|
# Usage: rightStrip "string" "pattern"
|
||||||
printf '%s\n' "${1%%$2}"
|
printf '%s\n' "${1%%$2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,6 +734,7 @@ function rightStrip() {
|
|||||||
# Returns:
|
# Returns:
|
||||||
# The modified string with the pattern removed from the start
|
# The modified string with the pattern removed from the start
|
||||||
function leftStrip() {
|
function leftStrip() {
|
||||||
|
# Usage: leftStrip "string" "pattern"
|
||||||
printf '%s\n' "${1##$2}"
|
printf '%s\n' "${1##$2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -747,7 +747,7 @@ function leftStrip() {
|
|||||||
# Returns:
|
# Returns:
|
||||||
# 0 if the unzip operation was successful, 1 if the unzip operation was unsuccessful
|
# 0 if the unzip operation was successful, 1 if the unzip operation was unsuccessful
|
||||||
function _unzip() {
|
function _unzip() {
|
||||||
# Set some locals
|
# Set some locals.
|
||||||
local zip_name="${1}"
|
local zip_name="${1}"
|
||||||
local folder_name="${2}"
|
local folder_name="${2}"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user