My dotfiles. Period.

slurp 799B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. #
  3. # Slurp - add everything, slurp into a WIP commit and push
  4. #
  5. die() {
  6. echo "$@" >&2
  7. exit 2
  8. }
  9. mkmsg() {
  10. #
  11. # Create the slurp message
  12. #
  13. local host=$(hostname)
  14. local date=$(date -Isec)
  15. echo "WIP slurp, $date at $host"
  16. }
  17. allowed_anything() {
  18. #
  19. # Is anything allowed in this repo?
  20. #
  21. test -f "$ok_file"
  22. }
  23. allowed_push() {
  24. #
  25. # Is push allowed in this repo?
  26. #
  27. grep -qxF PUSH "$ok_file"
  28. }
  29. main() {
  30. local git_root
  31. local ok_file
  32. local want_push=false
  33. git_root="$(git rev-parse --show-toplevel)" || die
  34. ok_file="$git_root/.git-slurp-ok"
  35. allowed_anything || die "you don't want this."
  36. allowed_push && want_push=true
  37. git add .
  38. git commit -m "$(mkmsg)"
  39. $want_push && git push
  40. }
  41. main