diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2017-06-22 13:24:24 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2017-06-22 13:24:24 +0900 |
commit | 224e1c6e886d95cdd07f7be59e838c5bb3606f83 (patch) | |
tree | bd9bf3b48706335c228b404e655a959e26982aea | |
parent | bc5c4a0891c6766d3479d228aae02a4c27793349 (diff) | |
download | git-test-224e1c6e886d95cdd07f7be59e838c5bb3606f83.tar.gz |
Teach -c|--clean option
-rwxr-xr-x | git-test | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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 |