summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrenton Leanhardt <bleanhar@redhat.com>2008-06-30 10:10:47 -0400
committerBrenton Leanhardt <bleanhar@redhat.com>2008-06-30 10:42:54 -0400
commita0d0674206dac58d0fec94ccbf6bf9616b14a87b (patch)
tree439badfa26daf0ae4dae049bbfb0e55e43059468
parente4918160f5ea6daed611b961e7368b417a473491 (diff)
Making 'start quick' truly non interactive
everest-sync needs some refactoring love to make it more readible
-rw-r--r--everest-sync/bin/everest-sync38
-rw-r--r--everest-sync/extra/everest-sync.spec2
2 files changed, 24 insertions, 16 deletions
diff --git a/everest-sync/bin/everest-sync b/everest-sync/bin/everest-sync
index 73a72b8..e7dbc36 100644
--- a/everest-sync/bin/everest-sync
+++ b/everest-sync/bin/everest-sync
@@ -64,7 +64,7 @@ Main {
def run
start do |git|
- git_action(git) do |b|
+ git_action(git, :non_interactive => true) do |b|
git.reset_hard(b)
end
end
@@ -73,7 +73,7 @@ Main {
def run
start(:interactive => true) do |git|
- # Being YACW (Yet Another Cheesy Wizard)
+ # Begin YACW (Yet Another Cheesy Wizard)
choose do |menu|
menu.prompt = "What would you like to do?"
@@ -217,27 +217,35 @@ Main {
# Namely, they can select a branch if there are multiple remote branches and with
# that branch they can do whatever action is contained in the 'block'--all the while
# recovering from git failures.
- def git_action(g, &block)
+ def git_action(g, opts={}, &block)
remote_branches = g.branches.find_all do |b|
(b.remote.to_s == @everest_repo) && b.name != 'HEAD'
end
- # Don't bother asking the user for a branch if there is only one
- if remote_branches.size == 1
- git_action_safe(g, remote_branches[0], &block)
+ # This is a horrible hack. The interactiveness should not be this method's
+ # concern.
+ if opts[:non_interactive]
+ remote_branches.each do |b|
+ git_action_safe(g, b, &block)
+ end
else
- choose do |m|
- m.prompt = "Select branch."
-
+ # Don't bother asking the user for a branch if there is only one
+ if remote_branches.size == 1
+ git_action_safe(g, remote_branches[0], &block)
+ else
+ choose do |m|
+ m.prompt = "Select branch."
- m.choices(*remote_branches) do |b|
- git_action_safe(g, b, &block)
- end
- m.choice("all branches") do
- remote_branches.each do |b|
+ m.choices(*remote_branches) do |b|
git_action_safe(g, b, &block)
- end
+ end
+
+ m.choice("all branches") do
+ remote_branches.each do |b|
+ git_action_safe(g, b, &block)
+ end
+ end
end
end
end
diff --git a/everest-sync/extra/everest-sync.spec b/everest-sync/extra/everest-sync.spec
index 6cb9a0c..ead572b 100644
--- a/everest-sync/extra/everest-sync.spec
+++ b/everest-sync/extra/everest-sync.spec
@@ -6,7 +6,7 @@
Summary: A tool for syncronizing Everest Repositories
Name: rubygem-%{gemname}
Version: 1.0.0
-Release: 4%{?dist}
+Release: 5%{?dist}
Group: Development/Languages
License: GPLv2
URL: https://fedorahosting.org/everest