perkeep/third_party/rewrite-imports.sh
mpl c2b746a086 pre-commit hook: warn about broken third party imports
Change-Id: Ib1315af2833a757093b36127b62d64abbd055963
2012-10-24 13:09:06 +02:00

22 lines
938 B
Bash
Executable File

#!/bin/sh
if [ "$1" = "-l" ]
then
find . -type f -name '*.go' -exec grep -E -l '"code.google.com/' {} \;
find . -type f -name '*.go' -exec grep -E -l '"launchpad.net/' {} \;
find . -type f -name '*.go' -exec grep -E -l '"github.com/' {} \;
find . -type f -name '*.go' -exec grep -E -l '"labix.org/' {} \;
elif [ "$1" = "-w" ]
then
find . -type f -name '*.go' -exec perl -pi -e 's!"code.google.com/!"camlistore.org/third_party/code.google.com/!' {} \;
find . -type f -name '*.go' -exec perl -pi -e 's!"launchpad.net/!"camlistore.org/third_party/launchpad.net/!' {} \;
find . -type f -name '*.go' -exec perl -pi -e 's!"github.com/!"camlistore.org/third_party/github.com/!' {} \;
find . -type f -name '*.go' -exec perl -pi -e 's!"labix.org/!"camlistore.org/third_party/labix.org/!' {} \;
else
cat << heredoc
usage: rewrite-imports.sh -l|-w"
-l: list files where a rewrite is needed"
-w: actually performs the rewrite"
heredoc
fi