diff --git a/tools/README.txt b/tools/README.txt index 6f6a91ae81..cfa8b87fc8 100644 --- a/tools/README.txt +++ b/tools/README.txt @@ -28,6 +28,10 @@ Used in tox environment pip-install. Only installs requirements (as opposed to test-requirements and verifies that all console-scripts have all modules needed. +code-search.sh +-------------- +Assuming you have a set of local git repos grep them all for interesting things. + cruft.sh -------- diff --git a/tools/code-search.sh b/tools/code-search.sh new file mode 100755 index 0000000000..b6172f2c1c --- /dev/null +++ b/tools/code-search.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +declare -a projects +in_projects=0 +base=$HOME + +while [ $# -gt 1 ] ; do + case "$1" in + --prefix) + prefix=$2 + shift 1 + ;; + --projects) + in_projects=1 + ;; + --) + break + ;; + *) + if [ "$in_projects" == 1 ] ; then + projects+=($1) + else + echo Unknown arg/context >&2 + exit 1 + fi + ;; + esac + shift 1 +done + +for prj in ${projects[@]} ; do + ( + cd $prj>/dev/null 2>&1 && \ + git grep -HEin $@ 2>/dev/null|sed -e "s,^,${prj#$prefix}:,g" + ) +done