Browse Source

bin: add `repo-find` helper

grepping `git ls-files`

Signed-off-by: Alejandro Mery <amery@geeks.cl>
master
Alejandro Mery 9 years ago
parent
commit
a06b94cc18
1 changed files with 44 additions and 0 deletions
  1. +44
    -0
      files/bin/repo-find

+ 44
- 0
files/bin/repo-find

@ -0,0 +1,44 @@
#!/bin/sh
COLOUR=auto
case "${1:-}" in
--color|--colour) COLOUR=true; shift ;;
--color=no|--colour=no) COLOUR=false; shift ;;
esac
if [ "$COLOUR" = auto -a -t 1 ]; then
COLOUR=true
fi
if $COLOUR; then
COLOUR="$(printf '\x1b[32m')"
NORMAL="$(printf '\x1b[39;49m')"
else
COLOUR=
NORMAL=
fi
while [ "$PWD" != / -a ! -s "$PWD/.repo/manifest.xml" ]; do
cd ..
done
if [ ! -s "$PWD/.repo/manifest.xml" ]; then
echo "not in a repo tree" >&2
exit 1
fi
GIT="`which git`"
git() {
local dir="$1"
shift
"$GIT" --git-dir "$dir/.git" --work-tree "$dir" "$@"
}
echo -n "$NORMAL"
repo list -p | while read p; do
if [ $# -gt 0 ]; then
git "$p" ls-files | grep "$@"
else
git "$p" ls-files
fi | sed -e "s|^|$COLOUR$p$NORMAL/|"
done

Loading…
Cancel
Save