fix git config arguments (#68)
ci/woodpecker/push/test Pipeline was successful Details
ci/woodpecker/push/deploy Pipeline was successful Details

#### 📖 Summary

- changed argument passing and testing in sub function

#### 📑 Test Plan

> 💡 Select your test plan for the code changes.

| Choice | Test Method       |
| :----: | :-----------      |
|      | CI pipeline tests |
|        | Custom test       |
|        | No test plan      |

##### Details / Justification

<!-- Add your test details or justification for missing tests here. -->

#### 📚 Additional Notes

- fixes #66

Co-authored-by: OCram85 <marco.blessing@googlemail.com>
Reviewed-on: #68
This commit is contained in:
OCram85 2023-09-15 09:06:27 +02:00
parent 21c6ef703f
commit aa23316413
1 changed files with 16 additions and 5 deletions

21
arkanum
View File

@ -243,13 +243,24 @@ EOF
}
function setGitConfig() {
if [[ "$#" != "2" ]]; then
sayE "Invalid arguments given. Please provide '<user>' and 'email'!" "Git"
#echo "function arg counter is; $#"
#echo "function args:$@"
if [[ "$#" != "4" ]]; then
sayE "Invalid arguments given. Please provide '<user>' and '<email>'!" "Git"
exit 1
fi
if [[ -z "$3" ]]; then
sayE "Invalid or empty username given!" "Git"
exit 1
fi
if [[ -z "$4" ]]; then
sayE "Invalid or empty email given!" "Git"
exit 1
fi
say "Setting global git config..." "Git"
git config --global user.name "$1"
git config --global user.email "$2"
git config --global user.name "$3"
git config --global user.email "$4"
say "Returning global config:" "Git"
git config --list --global
}
@ -287,7 +298,7 @@ function main() {
elif [[ "$1" == "git" ]]; then
# setup option
if [[ "$2" == "setup" ]]; then
setGitConfig "$3" "$4"
setGitConfig "$@"
else
sayE "Unknown option ($2) given for command 'git'!"
fi