From 52bc07bc848e993eacd30d555206d623af2d5839 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 18 May 2023 09:35:26 +0100 Subject: .gitcheck: improved coding style main() on top top-down order of logic Signed-off-by: Leah Rowe --- .gitcheck | 57 +++++++++++++++++++++++++++++++++------------------------ 1 file 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 +# SPDX-FileCopyrightText: 2023 Leah Rowe # 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 $@ -- cgit v1.2.1