From ce1678ec45b4b0df1c3195b926410e62641de431 Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Fri, 5 Aug 2022 12:44:06 -0400 Subject: Add git module --- .gitignore | 2 ++ dots | 4 ++-- modules/40-git/gitconfig | 14 ++++++++++++++ modules/40-git/install.sh | 21 +++++++++++++++++++++ modules/test/install.sh | 11 ----------- 5 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 .gitignore create mode 100644 modules/40-git/gitconfig create mode 100644 modules/40-git/install.sh delete mode 100644 modules/test/install.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0ddcba1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# we don't want this to be saved across machines +.firstrun diff --git a/dots b/dots index 3c1807b..72d9484 100755 --- a/dots +++ b/dots @@ -26,7 +26,7 @@ function main() { MODULES=modules/**/install.sh # perform preinstall tasks - REQUIRED_PACKAGES=() + PACKAGES=() for module in $MODULES; do # make sure we're not using something from previous runs unset -f preinstall @@ -43,7 +43,7 @@ function main() { done # install any requested packages - [[ ${#REQUIRED_PACKAGES[@]} -gt 0 ]] && packages::install ${REQUIRED_PACKAGES[@]} + [[ ${#PACKAGES[@]} -gt 0 ]] && packages::install ${PACKAGES[@]} # perform installation tasks for module in $MODULES; do diff --git a/modules/40-git/gitconfig b/modules/40-git/gitconfig new file mode 100644 index 0000000..2a66c5e --- /dev/null +++ b/modules/40-git/gitconfig @@ -0,0 +1,14 @@ +[user] + name = Galen Guyer + email = galen@galenguyer.com + signingkey = 7E54503B0CC743654BEB7187185693577B356767 +[gpg] + program = gpg +[commit] + gpgsign = true +[pull] + rebase = true +[alias] + lg = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all +[push] + autoSetupRemote = true diff --git a/modules/40-git/install.sh b/modules/40-git/install.sh new file mode 100644 index 0000000..890db77 --- /dev/null +++ b/modules/40-git/install.sh @@ -0,0 +1,21 @@ +_script="$(realpath ${BASH_SOURCE[0]})" +_scriptname="$(basename $_script)" +_scriptdir="$(dirname $_script)" +_modulename="$(basename $_scriptdir)" + +function preinstall() { + if ! [[ -x "$(command -v git)" ]]; then + PACKAGES+=("git") + fi +} + +function install() { + # backup old file if it exists and we haven't backed it up before + if [[ -f "$HOME/.gitconfig" ]] && ! [[ -f "$HOME/.gitconfig.bak" ]] && ! [[ -f "$_scriptdir/.firstrun" ]]; then + echo "making backup" + cp "$HOME/.gitconfig" "$HOME/.gitconfig.bak" + touch "$_scriptdir/.firstrun" + fi + + ln -f "$_scriptdir/gitconfig" "$HOME/.gitconfig" +} diff --git a/modules/test/install.sh b/modules/test/install.sh deleted file mode 100644 index 2adaf16..0000000 --- a/modules/test/install.sh +++ /dev/null @@ -1,11 +0,0 @@ -_script="$(realpath ${BASH_SOURCE[0]})" -_scriptname="$(basename $_script)" -_scriptdir="$(dirname $_script)" -_modulename="$(basename $_scriptdir)" - -#function preinstall() { -#} - -function install() { - echo "module name: $_modulename" -} -- cgit v1.2.3