From 7dec4cc4511fb96a8c574d8f91c38cc3cf817c4c Mon Sep 17 00:00:00 2001 From: Hans Goor Date: Sun, 18 Aug 2024 16:01:21 +0000 Subject: [PATCH] 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. --- install.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 9f3325f..8c5fad9 100755 --- a/install.sh +++ b/install.sh @@ -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