Plex plugin to to play various online streams (mostly Latvian).

applypatch-transform 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/sh
  2. #
  3. # An example hook script to transform a patch taken from an email
  4. # by git am.
  5. #
  6. # The hook should exit with non-zero status after issuing an
  7. # appropriate message if it wants to stop the commit. The hook is
  8. # allowed to edit the patch file.
  9. #
  10. # To enable this hook, rename this file to "applypatch-transform".
  11. #
  12. # This example changes the path of Lib/unittest/mock.py to mock.py
  13. # Lib/unittest/tests/testmock to tests and Misc/NEWS to NEWS, and
  14. # finally skips any patches that did not alter mock.py or its tests.
  15. set -eux
  16. patch_path=$1
  17. # Pull out mock.py
  18. filterdiff --clean --strip 3 --addprefix=a/mock/ -i 'a/Lib/unittest/mock.py' -i 'b/Lib/unittest/mock.py' $patch_path > $patch_path.mock
  19. # And the tests
  20. filterdiff --clean --strip 5 --addprefix=a/mock/tests/ -i 'a/Lib/unittest/test/testmock/*.py' -i 'b/Lib/unittest/test/testmock/*.py' $patch_path > $patch_path.tests
  21. # Lastly we want to pick up any NEWS entries.
  22. filterdiff --strip 2 --addprefix=a/ -i a/Misc/NEWS -i b/Misc/NEWS $patch_path > $patch_path.NEWS
  23. cp $patch_path $patch_path.orig
  24. # bash
  25. cat $patch_path.mock $patch_path.tests > $patch_path
  26. filtered=$(cat $patch_path)
  27. if [ -n "${filtered}" ]; then
  28. cat $patch_path.NEWS >> $patch_path
  29. exitcode=0
  30. else
  31. exitcode=1
  32. fi
  33. rm $patch_path.mock $patch_path.tests $patch_path.NEWS
  34. exit $exitcode