mirror of https://github.com/perkeep/perkeep.git
pre-commit hook: warn about broken third party imports
Change-Id: Ib1315af2833a757093b36127b62d64abbd055963
This commit is contained in:
parent
202c45a04a
commit
c2b746a086
|
@ -1,6 +1,22 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
exitstatus=0
|
||||
|
||||
#third_party imports.
|
||||
cd third_party
|
||||
rewrite=`./rewrite-imports.sh -l`
|
||||
cd ..
|
||||
if [ -n "$rewrite" ]
|
||||
then
|
||||
exitstatus=1
|
||||
for r in $rewrite
|
||||
do
|
||||
echo $r
|
||||
done
|
||||
echo "The above need their imports to be fixed. Use rewrite-imports.sh -w"
|
||||
fi
|
||||
|
||||
#gofmt and trailing space errors
|
||||
committed=`git diff-index --cached --name-only HEAD`
|
||||
for c in $committed
|
||||
do
|
||||
|
|
|
@ -1,7 +1,21 @@
|
|||
#!/bin/sh
|
||||
|
||||
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/!' {} \;
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue