Skip to content

Commit

Permalink
Improved how upstream is configured or removed
Browse files Browse the repository at this point in the history
  • Loading branch information
aho-dips committed Dec 14, 2023
1 parent 7cf844d commit 0d27eee
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions smud-cli/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,29 @@ version()

set_upstream()
{

default_upstream="https://github.com/DIPSAS/DIPS-GitOps-Template.git"
if [ $help ]; then
echo "${bold}smud set-upstream${normal}: Set upstream https://github.com/DIPSAS/DIPS-GitOps-Template.git"
echo "${bold}smud set-upstream${normal}: Set upstream"
printf "With Only ${green}set-upstream${normal}, Upstream '$default_upstream' wil be configured. \n"
printf "With ${green}set-upstream <value>${normal}, Upstream '<value>' will be configured. \n"
printf "With ${green}set-upstream -${normal}, Upstream will be removed. \n"
return
fi
new_value="${arg[0]}"
remote_upstream=$(git config --get remote.upstream.url)
if [ ! $remote_upstream ]; then
remote_upstream="https://github.com/DIPSAS/DIPS-GitOps-Template.git"
if [ $new_value ]; then
remote_upstream=$new_value
if [ $remote_upstream ]; then
git remote rm upstream
fi
if [ "$remote_upstream" = "-" ]; then
printf "${gray}Upstream is removed${normal}\n"
else
git remote add upstream $remote_upstream
printf "${gray}Upstream configured with '$remote_upstream' ${normal}\n"
fi
elif [ ! $remote_upstream ]; then
remote_upstream=$default_upstream
git remote add upstream $remote_upstream
printf "${gray}Upstream configured with '$remote_upstream' ${normal}\n"
else
Expand Down

0 comments on commit 0d27eee

Please sign in to comment.