Files
scst/scripts/clean-source-tree
T
Gleb Chesnokov 1a1a75d9ed scripts: Remove non-Git VCS support
Mercurial branches remain in source-listing and cleanup helpers after
Subversion support was retired. SCST development now uses Git.

Remove Mercurial detection and commands together with stale Subversion
wording. Preserve the existing no-VCS source-list fallback and all Git
behavior.
2026-08-21 19:58:59 +03:00

52 lines
904 B
Bash
Executable File

#!/usr/bin/env bash
shopt -s nullglob
usage() {
echo "Usage: $(basename "$0") [ -x <exclude> ]*"
exit 1
}
remove_empty_directories() {
find . -depth -type d |
sed 's|^\./||' |
grep -Ev '^\.$|^\.git/|^\.git$' |
while read -r d; do
for f in "$d"/{*,.*}; do
if ! [ -e "$f" ]; then
rmdir "$d"
fi
break
done
done
}
git_options=(-e TAGS)
while [ "${1#-}" != "$1" ]; do
case "$1" in
-x)
git_options+=(-e "$2")
shift; shift;;
*)
usage;;
esac
done
for d in "${@-.}"; do
(
if cd "$d"; then
if [ -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 "${git_options[@]}" >/dev/null
remove_empty_directories
else
echo "$0: $d: not administered by Git."
fi
fi
)
done