aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2017-06-22 13:24:24 +0900
committerKazuki Yamaguchi <k@rhe.jp>2017-06-22 13:24:24 +0900
commit224e1c6e886d95cdd07f7be59e838c5bb3606f83 (patch)
treebd9bf3b48706335c228b404e655a959e26982aea
parentbc5c4a0891c6766d3479d228aae02a4c27793349 (diff)
downloadgit-test-224e1c6e886d95cdd07f7be59e838c5bb3606f83.tar.gz
Teach -c|--clean option
-rwxr-xr-xgit-test9
1 files changed, 9 insertions, 0 deletions
diff --git a/git-test b/git-test
index f868d87..ea01461 100755
--- a/git-test
+++ b/git-test
@@ -40,6 +40,9 @@ OPTIONS
When this option is not specified, the value(s) of the
configuration 'git-test.test' is used.
+ -c, --clean
+ Run "git clean -xdf" just before checking out the first tree.
+
-n, --dry-run
Do everything except actually check out the tree and run the test
commands.
@@ -97,6 +100,7 @@ end
opts = {
test: nil,
+ clean: false,
dry_run: false,
keep_going: false,
force: false,
@@ -104,6 +108,7 @@ opts = {
}
OptionParser.new { |o|
o.on("-t <command>", "--test=<command>") { |v| (opts[:test] ||= []) << v }
+ o.on("-c", "--clean") { opts[:clean] = true }
o.on("-n", "--dry-run") { opts[:dry_run] = true }
o.on("-k", "--keep-going") { opts[:keep_going] = true }
o.on("-f", "--force") { opts[:force] = true }
@@ -150,6 +155,10 @@ puts color(:green, "Preparing a working tree at #{opts[:checkout]}...")
unless opts[:dry_run]
if File.directory?(opts[:checkout])
sh("git", "-C", opts[:checkout], "reset", "--hard")
+ if opts[:clean]
+ puts color(:green, "Cleaning the working tree...")
+ sh("git", "-C", opts[:checkout], "clean", "-xdf")
+ end
else
sh("git", "worktree", "add", "--detach", opts[:checkout])
end