Merge branch 'svn-trunk'

This commit is contained in:
Bart Van Assche
2018-01-21 19:46:16 -08:00
2 changed files with 62 additions and 12 deletions

54
scripts/clean-source-tree Executable file
View File

@@ -0,0 +1,54 @@
#!/usr/bin/env bash
shopt -s nullglob
remove_empty_directories() {
find . -depth -type d |
sed 's|^\./||' |
grep -Ev '^\.$|^\.svn/|/\.svn/|/\.svn$|^\.hg/|^\.hg$|^\.git/|^\.git$' |
while read -r d; do
for f in "$d"/{*,.*}; do
if ! [ -e "$f" ]; then
rmdir "$d"
fi
break
done
done
}
if [ $# = 0 ]; then
# shellcheck source=clean-source-tree
. "$0" .
else
for d in "$@"; do
(
if cd "$d"; then
if [ -e .svn ]; then
if ! type -p svn >&/dev/null; then
echo "$0: svn: not found."
exit 0
fi
"$(dirname "$0")"/list-non-source-files |
while read -r f; do
if [ "$f" != "TAGS" ]; then rm -rf -- "$f"; fi;
done
elif [ -e .git ] || [ -e ../.git ]; then
if ! type -p git >&/dev/null; then
echo "$0: git: not found."
exit 0
fi
git clean -f -d -x -e TAGS >/dev/null
remove_empty_directories
elif [ -e .hg ] || [ -e ../.hg ]; then
if ! type -p hg >&/dev/null; then
echo "$0: hg: not found."
exit 0
fi
hg purge --all
else
echo "$0: $d: not administered by Subversion, Git or Mercurial."
fi
fi
)
done
fi

View File

@@ -1,29 +1,25 @@
#!/bin/bash
inode() {
ls -id "$1" | { read a b; echo "$a"; }
}
list_source_files() {
local d r
d="$(cd "$1" && echo "$PWD")"
r="$d"
inode_root="$(inode /)"
while [ $(inode "$r") != "${inode_root}" -a \
! -e "$r/.svn" -a ! -e "$r/.git" -a ! -e "$r/.hg" ]; do
r="$r/.."
while [ "$r" != "/" ] && [ ! -e "$r/.svn" ] && [ ! -e "$r/.git" ] &&
[ ! -e "$r/.hg" ]; do
r="$(dirname "$r")"
done
if [ -e "$r/.svn" ]; then
(
cd "$d"
cd "$d" || exit $?
svn status -v | \
grep -vE '^[D?]|^Performing|^$' | \
cut -c41- | \
while read f; do
cut -c3- | \
while read -r a b c f; do
if [ -f "$f" ]; then
echo "$f"
echo "$a $b $c" >/dev/null
echo "$f"
fi
done
)