Add a basic git setup function in case we cannot stow.

This can happen in cases where we use a devcontainer which already has a
gitconfig in the user home folder. In that case, apply the most important
settings and let the rest remain for what it is. This happens with, for example,
devpod.
This commit is contained in:
Hans Goor 2024-08-18 16:01:21 +00:00
parent 1eb8de172b
commit 7dec4cc451
No known key found for this signature in database

View file

@ -11,6 +11,21 @@ function do_stow() {
stow "${opts[@]}" "$package"
}
function basic_git_setup() {
if ! command -v git &> /dev/null; then
echo "[!] Git is not installed! Not running git setup."
return 1
fi
git config --global user.name "Hans Goor"
git config --global user.email "me@eyedevelop.org"
git config --global push.autoSetupRemote true
git config --global pull.rebase true
git config --global commit.gpgsign true
git config --global merge.ff no
git config --global init.defaultBranch main
}
set -eo pipefail
DOTFILES_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
@ -28,7 +43,7 @@ mkdir -p "${TARGET_DIR}/.config"
# Install SSH separately, as it requres a different target.
do_stow ssh "${TARGET_DIR}/.ssh" || true
do_stow tmux || true
do_stow git || true
do_stow git || (basic_git_setup || true)
do_stow zsh || true
do_stow nvim "${TARGET_DIR}/.config" || true