.gitcheck: improved coding style

main() on top

top-down order of logic

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2023-05-18 09:35:26 +01:00
parent 83235fb96b
commit 52bc07bc84
+31 -22
View File
@@ -1,40 +1,49 @@
#!/bin/sh #!/bin/sh
# SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com> # SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
# SPDX-License-Identifier: GPL-3.0-only # SPDX-License-Identifier: GPL-3.0-only
Set_placeholder(){ git_name="lbmkplaceholder"
# Check if username and or email is set. git_email="placeholder@lbmkplaceholder.com"
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'
fi
}
Clean(){ main()
if [ "$(git config user.name)" = "lbmkplaceholder" ]; then {
git config --unset user.name
fi
if [ "$(git config user.email)" = "placeholder@lbmkplaceholder.com" ]; then
git config --unset user.email
fi
}
Run(){
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
if [ "${1}" = "clean" ]; then if [ "${1}" = "clean" ]; then
Clean clean
fi fi
else else
Set_placeholder set_placeholder
# Check coreboot as well to prevent errors during building # Check coreboot as well to prevent errors during building
if [ -d coreboot ]; then if [ -d coreboot ]; then
cd coreboot cd coreboot
Set_placeholder set_placeholder
cd - cd -
fi fi
fi fi
} }
Run $@ >/dev/null 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 "${git_name}"
git config user.email \
|| git config user.email "${git_email}"
fi
}
clean()
{
if [ "$(git config user.name)" = "${git_name}" ]; then
git config --unset user.name
fi
if [ "$(git config user.email)" = "${git_email}" ]; then
git config --unset user.email
fi
}
main $@