Merge bitcoin/bitcoin#34776: guix: Make guix-clean more careful

be6d24ec22 guix: Make guix-clean less destructive (Hodlinator)

Pull request description:

  * Show preview and ask for confirmation before git clean unless used with "--force"
  * Error out when user tries to pass args such as "guix-clean --help"

ACKs for top commit:
  kevkevinpal:
    reACK [be6d24e](be6d24ec22)
  janb84:
    ACK be6d24ec22
  sedited:
    ACK be6d24ec22
  willcl-ark:
    ACK be6d24ec22

Tree-SHA512: 19fc6e5dc68f2886f5fb970ff39d040a8088eedca56ad5b86622297614b0d164df9ddd5a8b24b972060e9dcde732de5e3346866b53963524a4277a0a56220570
This commit is contained in:
merge-script
2026-03-12 10:23:00 +00:00

View File

@@ -9,6 +9,14 @@ set -e -o pipefail
# shellcheck source=libexec/prelude.bash
source "$(dirname "${BASH_SOURCE[0]}")/libexec/prelude.bash"
# Parse supported args
FORCE=0
if [[ $* == "--force" ]]; then
FORCE=1
elif [ $# != 0 ]; then
echo "Script only takes optional --force arg."
exit 1
fi
###################
## Sanity Checks ##
@@ -80,4 +88,14 @@ for precious_dirs_file in "${found_precious_dirs_files[@]}"; do
done < "$precious_dirs_file"
done
if [[ $FORCE == 0 ]]; then
git clean -nxdff "${exclude_flags[@]}"
read -p "Proceed? (y/n) " -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborted."
exit 1
fi
fi
git clean -xdff "${exclude_flags[@]}"