1
1

Trivial helper script to git clean submodules

Since we added the use of git submodules recently, this trivial script
has been helpful to me to "git clean" not only the top-level Open MPI
repo, but also all the included submodules, too.

NOTE: this script does the (harsh) "git clean -dfx" command, which
deletes everything that git does not know about.  Use with care!

Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
Этот коммит содержится в:
Jeff Squyres 2020-07-06 04:57:42 -07:00
родитель a7ed13d74a
Коммит 86f4128e12

32
contrib/git-clean.sh Исполняемый файл
Просмотреть файл

@ -0,0 +1,32 @@
#!/bin/bash
# Copyright (c) 2020 Cisco Systems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Trivial helper script to git clean a tree and all of its submodules.
set -euo pipefail
# Top git dir
root=$(git rev-parse --show-toplevel)
cd $root
# Clean the top-level dir
echo "=== Cleaning top-level git directory"
git clean -dfx .
submodule_dirs=$(git submodule status | awk '{print $2}')
if test -z "$submodule_dirs"; then
echo "No submodules to clean"
exit 0
fi
for dir in $submodule_dirs; do
echo "=== Cleaning submodule: $dir"
cd $dir
git clean -dfx .
cd $root
done