diff --git a/src/octozipo b/src/octozipo index d40d03b..3f983d2 100755 --- a/src/octozipo +++ b/src/octozipo @@ -3,8 +3,8 @@ # Program name PROGRAM_NAME="Octozipo" PROGRAM_CODE="octozipo" -PROGRAM_VERSION="2.0.1" -PROGRAM_V="2.0" +PROGRAM_VERSION="2.2.1" +PROGRAM_V="2.2" # PROGRAM_URL="https://git.vdm.dev/octoleo/${PROGRAM_CODE}" # Do some prep work @@ -188,12 +188,14 @@ setNewRepository() { setExistingRepository() { # Notifies the user that the existing repository is being updated. _echo "[info] Update ($VDM_REPO_NAME) existing repository" - # Checks if there are any changes in the repository. if [[ -z $(git status --porcelain) ]]; then # If there are no changes, inform the user. _echo "[info] No changes found in ($VDM_REPO_NAME v$VDM_VERSION) repository" else + # set repository user details + setUserDetails + # If there are changes, create a commit message. commit_msg="update" if ! [ "$(git tag -l "v$VDM_VERSION")" ]; then @@ -275,6 +277,9 @@ setGitInit() { # If there are no changes, inform the user. _echo "[info] No changes found in repository" else + # set repository user details + setUserDetails + # If there are changes, check if a Git tag with the version number exists. if [ -z "$VDM_VERSION" ] || git tag -l "v$VDM_VERSION" > /dev/null 2>&1; then # If it does not exist or if there is no version number, create a commit with the "update" message. @@ -309,6 +314,53 @@ setGitInit() { return 0 } +# Function: setUserDetails +# Purpose: Set Git user details based on environment variables +# +# Arguments: +# None +# +# Environment Variables: +# GIT_AUTHOR_NAME - Git author name +# GIT_AUTHOR_EMAIL - Git author email +# GIT_GPG_SIGN - Git GPG sign (true or false) +# GIT_SSH_KEY_PATH - Path to the Git SSH key +# GIT_GPG_KEY - Git GPG key +# +# Returns: +# None +setUserDetails () { + # Set Git author name + if [ -n "${GIT_AUTHOR_NAME+x}" ]; then + git config user.name "${GIT_AUTHOR_NAME}" + _echo "[info] Git author name set to: ${GIT_AUTHOR_NAME}" + fi + + # Set Git author email + if [ -n "${GIT_AUTHOR_EMAIL+x}" ]; then + git config user.email "${GIT_AUTHOR_EMAIL}" + _echo "[info] Git author email set to: ${GIT_AUTHOR_EMAIL}" + fi + + # Set Git GPG sign + if [ -n "${GIT_GPG_SIGN+x}" ]; then + git config commit.gpgsign "${GIT_GPG_SIGN}" + _echo "[info] Git GPG sign set to: ${GIT_GPG_SIGN}" + fi + + # Set Git SSH key path + if [ -n "${GIT_SSH_KEY_PATH+x}" ]; then + git config core.sshCommand "ssh -i ${GIT_SSH_KEY_PATH}" + _echo "[info] Git SSH key path set to: ${GIT_SSH_KEY_PATH}" + fi + + # Set Git GPG key + if [ -n "${GIT_GPG_KEY+x}" ]; then + git config user.signingkey "${GIT_GPG_KEY}" + _echo "[info] Git GPG key set to: ${GIT_GPG_KEY}" + fi +} + # setGitCommit - Makes a Git commit with a specified commit message and creates a Git tag # # setGitCommit adds all changes to the Git index, makes a Git commit with the specified commit message, @@ -821,7 +873,7 @@ function runUpdate() { } # set the defaults -VDM_ZIP_DIR="$PWD" +: "${VDM_ZIP_DIR:=$PWD}" VDM_ORG="joomla" VDM_GIT_URL="git.vdm.dev" VDM_PUSH_CREATE=false