.gitcheck 764 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env bash
  2. # SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
  3. # SPDX-License-Identifier: GPL-3.0-only
  4. Set_placeholder(){
  5. git config user.name || git config user.name 'osbmkplaceholder'
  6. git config user.email || git config user.email 'placeholder@osbmkplaceholder.com'
  7. }
  8. Clean(){
  9. if [ "$(git config user.name)" = "osbmkplaceholder" ]; then
  10. git config --unset user.name
  11. fi
  12. if [ "$(git config user.email)" = "placeholder@osbmkplaceholder.com" ]; then
  13. git config --unset user.email
  14. fi
  15. }
  16. Run(){
  17. if [ ! -d ".git/" ]; then
  18. git init
  19. fi
  20. if [ "${1}" = "clean" ]; then
  21. Clean
  22. else
  23. # Check if username and or email is set.
  24. if ! git config user.name || git config user.email ; then
  25. Set_placeholder
  26. fi
  27. fi
  28. }
  29. Run >/dev/null