diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-01-12 12:28:15 +0000 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-01-12 12:28:15 +0000 |
commit | 639b9795c0ada8432f8b42a59509e654e1a2bc7b (patch) | |
tree | 2d904b6d21ad58271d83e836ebaabc609d3f439d | |
parent | a7209abf52ec7ae41fa2e1f607b7d49ef45fca6a (diff) | |
download | dotfiles-639b9795c0ada8432f8b42a59509e654e1a2bc7b.tar.gz |
confirm before dropping files deleted by commit
-rwxr-xr-x | bin/annex-drop-files-deleted-by-commit | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/bin/annex-drop-files-deleted-by-commit b/bin/annex-drop-files-deleted-by-commit index 1e98d9aa..9f33a8e5 100755 --- a/bin/annex-drop-files-deleted-by-commit +++ b/bin/annex-drop-files-deleted-by-commit @@ -1,6 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2019 Sean Whitton +# Copyright (C) 2019-2020 Sean Whitton # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,11 +24,14 @@ use 5.028; use strict; use warnings; +use lib "$ENV{HOME}/lib/perl5"; use File::Path qw(rmtree); use File::Temp qw(tempdir); use Git::Wrapper; use Try::Tiny; +use Local::ScriptStatus; +use Local::Interactive qw(prompt_yn); # git wrapper setup my $git = Git::Wrapper->new("."); @@ -58,8 +61,14 @@ for (@ARGV) { = $git->diff({ name_only => 1, diff_filter => 'D' }, "$commit~1..$commit"); $worktree->checkout("$commit~1"); + + say_spaced_bullet("Will drop" + . (grep(/\A--force\z/, @drop_args) ? " with --force:" : ":")); + say for @deleted_files; + say ''; # bypass Git::Wrapper so output goes to terminal - system('git', '-C', $temp, 'annex', 'drop', @drop_args, @deleted_files); + system('git', '-C', $temp, 'annex', 'drop', @drop_args, @deleted_files) + if prompt_yn("Go ahead with this?"); } # we can't use `git worktree remove` because the way git-annex # worktree support works breaks that command: git-annex replaces the |