runtime: Fix shellcheck issues in git_push.sh

Fix shellcheck warnings and notes identified by running
shellcheck --severity=style.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
This commit is contained in:
Fabiano Fidêncio
2026-04-21 12:32:07 +02:00
parent 4c490579d5
commit 77e558deb0

View File

@@ -8,24 +8,24 @@ git_repo_id=$2
release_note=$3
git_host=$4
if [ "$git_host" = "" ]; then
if [ "${git_host}" = "" ]; then
git_host="github.com"
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
echo "[INFO] No command line input provided. Set \$git_host to ${git_host}"
fi
if [ "$git_user_id" = "" ]; then
if [ "${git_user_id}" = "" ]; then
git_user_id="GIT_USER_ID"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
echo "[INFO] No command line input provided. Set \$git_user_id to ${git_user_id}"
fi
if [ "$git_repo_id" = "" ]; then
if [ "${git_repo_id}" = "" ]; then
git_repo_id="GIT_REPO_ID"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
echo "[INFO] No command line input provided. Set \$git_repo_id to ${git_repo_id}"
fi
if [ "$release_note" = "" ]; then
if [ "${release_note}" = "" ]; then
release_note="Minor update"
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
echo "[INFO] No command line input provided. Set \$release_note to ${release_note}"
fi
# Initialize the local directory as a Git repository
@@ -35,17 +35,18 @@ git init
git add .
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
git commit -m "${release_note}"
# Sets the new remote
git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "${git_remote}" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
# shellcheck disable=SC2154
if [ "${GIT_TOKEN}" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
git remote add origin "https://${git_host}/${git_user_id}/${git_repo_id}.git"
else
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
git remote add origin "https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git"
fi
fi