pre-commit 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env bash
  2. #=============================================================================
  3. # CMake - Cross Platform Makefile Generator
  4. # Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
  5. #
  6. # Distributed under the OSI-approved BSD License (the "License");
  7. # see accompanying file Copyright.txt for details.
  8. #
  9. # This software is distributed WITHOUT ANY WARRANTY; without even the
  10. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. # See the License for more information.
  12. #=============================================================================
  13. die() {
  14. echo 'pre-commit hook failure' 1>&2
  15. echo '-----------------------' 1>&2
  16. echo '' 1>&2
  17. echo "$@" 1>&2
  18. exit 1
  19. }
  20. if test -z "$HOOKS_ALLOW_KWSYS"; then
  21. # Disallow changes to KWSys
  22. files=$(git diff-index --name-only --cached HEAD -- Source/kwsys) &&
  23. if test -n "$files"; then
  24. die 'Changes to KWSys files
  25. '"$(echo "$files" | sed 's/^/ /')"'
  26. cannot be committed through Git. KWSys is kept in a CVS repository
  27. shared by several projects. A robot replays changes committed there
  28. into the Source/kwsys directory in CMake. Please send changes to
  29. this directory separately. Run
  30. git reset HEAD -- Source/kwsys
  31. to unstage these changes and then
  32. git diff -- Source/kwsys > kwsys.patch
  33. to construct the patch. Alternatively, set environment variable
  34. HOOKS_ALLOW_KWSYS=1
  35. to disable this check and commit the changes locally.'
  36. fi
  37. fi