Skip to content

Commit

Permalink
fix(git): set default config for git pull to prevent cryptic error me…
Browse files Browse the repository at this point in the history
…ssage
  • Loading branch information
avouacr authored Nov 24, 2024
1 parent 63490ad commit 441f124
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions scripts/onyxia-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,18 @@ if [ "`which git`" != "" ]; then
fi

# Git config
if [[ $(id -u) = 0 ]]; then
git_config="system"
else
git_config="global"
fi
if [ -n "$GIT_USER_NAME" ]; then
git config --"$git_config" user.name "$GIT_USER_NAME"
git config --global user.name "$GIT_USER_NAME"
fi
if [ -n "$GIT_USER_MAIL" ]; then
git config --"$git_config" user.email "$GIT_USER_MAIL"
git config --global user.email "$GIT_USER_MAIL"
fi
if [ -n "$GIT_CREDENTIALS_CACHE_DURATION" ]; then
git config --"$git_config" credential.helper "cache --timeout=$GIT_CREDENTIALS_CACHE_DURATION"
git config --global credential.helper "cache --timeout=$GIT_CREDENTIALS_CACHE_DURATION"
fi
# Default strategy when performing a git pull
# Use Git's former default (fast-forward if possible, else merge) to avoid cryptic error message
git config --global pull.rebase false

# Fix permissions
[ -d ~/.cache/git ] && chown -R ${USERNAME}:${GROUPNAME} ~/.cache/git
Expand Down

0 comments on commit 441f124

Please sign in to comment.