pre-commit 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. should not be made directly in CMake. KWSys is kept in its own Git
  27. repository and shared by several projects. Please visit
  28. http://public.kitware.com/Wiki/KWSys/Git
  29. to contribute changes directly to KWSys. Run
  30. git reset HEAD -- Source/kwsys
  31. to unstage these changes. Alternatively, set environment variable
  32. HOOKS_ALLOW_KWSYS=1
  33. to disable this check and commit the changes locally.'
  34. fi
  35. fi