summaryrefslogtreecommitdiff
path: root/.gitcheck
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-05-18 09:35:26 +0100
committerLeah Rowe <leah@libreboot.org>2023-05-18 09:35:26 +0100
commit52bc07bc848e993eacd30d555206d623af2d5839 (patch)
treef054204fda4d70b7f52cbcca5884c4bb4265b711 /.gitcheck
parent83235fb96bd2a426c5d40ce2ad1ccc18049b91bd (diff)
.gitcheck: improved coding style
main() on top top-down order of logic Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to '.gitcheck')
-rwxr-xr-x.gitcheck57
1 files changed, 33 insertions, 24 deletions
diff --git a/.gitcheck b/.gitcheck
index 6dfdb362..3fc20b6c 100755
--- a/.gitcheck
+++ b/.gitcheck
@@ -1,40 +1,49 @@
#!/bin/sh
# SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
+# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
# SPDX-License-Identifier: GPL-3.0-only
-Set_placeholder(){
+git_name="lbmkplaceholder"
+git_email="placeholder@lbmkplaceholder.com"
+
+main()
+{
+ if [ $# -gt 0 ]; then
+ if [ "${1}" = "clean" ]; then
+ clean
+ fi
+ else
+ set_placeholder
+
+ # Check coreboot as well to prevent errors during building
+ if [ -d coreboot ]; then
+ cd coreboot
+ set_placeholder
+ cd -
+ fi
+ fi
+}
+
+set_placeholder()
+{
# Check if username and or email is set.
if ! git config user.name || git config user.email ; then
- git config user.name || git config user.name 'lbmkplaceholder'
- git config user.email || git config user.email 'placeholder@lbmkplaceholder.com'
+ git config user.name \
+ || git config user.name "${git_name}"
+ git config user.email \
+ || git config user.email "${git_email}"
fi
}
-Clean(){
- if [ "$(git config user.name)" = "lbmkplaceholder" ]; then
+clean()
+{
+ if [ "$(git config user.name)" = "${git_name}" ]; then
git config --unset user.name
fi
- if [ "$(git config user.email)" = "placeholder@lbmkplaceholder.com" ]; then
+ if [ "$(git config user.email)" = "${git_email}" ]; then
git config --unset user.email
fi
}
-Run(){
-if [ $# -gt 0 ]; then
- if [ "${1}" = "clean" ]; then
- Clean
- fi
-else
- Set_placeholder
-
- # Check coreboot as well to prevent errors during building
- if [ -d coreboot ]; then
- cd coreboot
- Set_placeholder
- cd -
- fi
-fi
-}
-
-Run $@ >/dev/null
+main $@