Files
scst/scripts/list-source-files
Bart Van Assche f9242eb1ae scripts: Merge r5177:5337 from trunk
git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/2.2.x@5373 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2014-03-25 16:29:07 +00:00

49 lines
1000 B
Bash
Executable File

#!/bin/bash
list_source_files() {
local d r
d="$(cd "$1" && echo "$PWD")"
r="$d"
while [ "$r" != "/" -a ! -e "$r/.svn" -a ! -e "$r/.git" -a ! -e "$r/.hg" ]; do
r="$(dirname "$r")"
done
if [ -e "$r/.svn" ]; then
(
cd "$d"
svn status -v | \
grep -vE '^[D?]|^Performing|^$' | \
cut -c41- | \
while read f; do
if [ -f "$f" ]; then
echo "$f"
fi
done
)
elif [ -e "$r/.git" ]; then
subdir="${d#${r}}"
if [ "$r" != "" ]; then
( cd "$d" && git ls-tree --name-only -r HEAD ) | sed "s|^$subdir/||"
else
echo "Ignored directory $1" >&2
fi
elif [ -e "$r/.hg" ]; then
subdir="${d#${r}}"
if [ -n "${subdir}" ]; then
subdir="${subdir#/}/"
hg manifest | sed -n "s|^$subdir||p"
else
hg manifest
fi
else
echo "Not under source control: $1 ?" >&2
fi
}
if [ $# = 0 ]; then
list_source_files "$PWD"
else
for d in "$@"; do list_source_files "$d"; done
fi