Allow user-defined git config

This commit is contained in:
Manuel Thalmann 2024-07-20 01:31:04 +02:00
parent 2c2c2889c2
commit 38ed0780f8
2 changed files with 30 additions and 10 deletions

View file

@ -24,4 +24,6 @@ for name in (echo "$users" | jq '.[]' --raw-output0 | string split0)
while ! sudo passwd "$name"
echo "An error occurred! Please try again."
end
source "$dir/../Software/git/main.fish" configure user "$name"
end

View file

@ -7,21 +7,39 @@ begin
echo "git"
end
function configureSW -S -V dir
function configureSW -S -V dir -a scope name
source "$dir/../../Scripts/config.fish"
set -l branch "valhalla.git.defaultBranch"
set -l root
set -l configArgs
function setConfig
sudo git config --system $argv
sudo git config $configArgs $argv
end
if [ -z "$scope" ] || [ "$scope" = "system" ]
set -l root "valhalla"
set -l configArgs "--system"
else
set -l root "valhalla.users.$name"
set -l configArgs "--global"
set -l displayName "$root.displayName"
set -l mailAddress "$root.mailAddress"
if isSet "$displayName"
setConfig user.name (getConfig "$displayName")
end
if isSet "$mailAddress"
setConfig user.email (getConfig "$mailAddress")
end
end
set -l branch "$root.git.defaultBranch"
if isSet "$branch"
setConfig init.defaultBranch (getConfig "$branch")
end
setConfig user.name "Manuel Thalmann"
setConfig user.email "m@nuth.ch"
begin # Git Flow
set -l dir (mktemp -d)
@ -39,13 +57,13 @@ begin
yes "" | git flow init &> /dev/null
if isSet "$mainKey"
sudo git flow config set --system master (getConfig "$mainKey") > /dev/null
sudo git flow config set $configArgs master (getConfig "$mainKey") > /dev/null
else
true
end
if isSet "$devKey"
sudo git flow config set --system develop (getConfig "$devKey") > /dev/null
sudo git flow config set $configArgs develop (getConfig "$devKey") > /dev/null
else
true
end
@ -56,8 +74,8 @@ begin
end
begin # Aliases
set -l key valhalla.git.aliases
set -l aliases (getConfig "$key" --json)
set -l key git.aliases
set -l aliases (getConfig "$root.$key" --json)
for name in (echo "$aliases" | jq 'keys[]' --raw-output0 | string split0)
setConfig "alias.$name" (getConfig "$key.$name")