[tools] Add a tool to grep local repos
Sean wanted to know which repos still use mox/mox 3 which can be done with this tool like: tools/code-search.sh --prefix ~/projects/openstack/ \ --projects ~/projects/openstack/*/* \ -- mox origin/master -- *requirements.txt setup.cfg The prefix is essentially a sting to remove from the project name. So the example above would change: /home/tony/projects/openstack/openstack/astara => openstack/astara Change-Id: I927bc96b6eafd2d95dc008b7f1a4374eb9f725b4
This commit is contained in:
parent
bfbb44a9b9
commit
0592ee179b
@ -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
|
||||
--------
|
||||
|
||||
|
48
tools/code-search.sh
Executable file
48
tools/code-search.sh
Executable file
@ -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
|
Loading…
Reference in New Issue
Block a user