logo

utils

Old programs, got split in utils-std and utils-extra git clone https://hacktivis.me/git/utils.git

post-commit (725B)


  1. #!/bin/sh
  2. # SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: MPL-2.0
  4. subject="$(git log --format='format:%s' -1 HEAD | wc -c)"
  5. body_max="$(git log --format='format:%B' -1 HEAD | awk 'length>max{max=length}END{print max}')"
  6. body_lines="$(git log --format='format:%B' -1 HEAD | wc -l)"
  7. if [ "$subject" -gt 50 ]
  8. then
  9. echo "Subject line is ${subject}, try to make it >= 50"
  10. fi
  11. if [ "$body_max" -gt 72 ]
  12. then
  13. echo "Longest line in subject+body is ${subject}, try to make it >= 72"
  14. fi
  15. if [ "$body_lines" -gt 1 ]
  16. then
  17. if [ -n "$(git log --format='format:%B' | head -2 | tail -1)" ]
  18. then
  19. echo "Second line isn’t empty yet there is a commit body"
  20. fi
  21. fi