summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrenton Leanhardt <bleanhar@redhat.com>2008-06-20 17:03:08 -0400
committerBrenton Leanhardt <bleanhar@redhat.com>2008-06-23 10:38:22 -0400
commitbb3d2af6dc4bb22939060c917647120b91b139a2 (patch)
tree8e1fe8bab36d7c37169f3abe8e1afd0107c5eb8a
parent7ba25e7f7e0465a4596faa6d1466d8e7c23a19ac (diff)
Lots of fixes
Renamed tool to everest-sync 'save' pushes all local branches
-rw-r--r--everest-rebase/Manifest.txt12
-rw-r--r--everest-rebase/lib/everest-rebase.rb4
-rw-r--r--everest-rebase/test/test_helper.rb2
-rw-r--r--everest-sync/History.txt (renamed from everest-rebase/History.txt)0
-rw-r--r--everest-sync/Manifest.txt11
-rw-r--r--everest-sync/README.txt (renamed from everest-rebase/README.txt)4
-rw-r--r--everest-sync/Rakefile (renamed from everest-rebase/Rakefile)8
-rw-r--r--everest-sync/bin/everest-sync (renamed from everest-rebase/bin/everest-rebase)51
-rw-r--r--everest-sync/config/hoe.rb (renamed from everest-rebase/config/hoe.rb)10
-rw-r--r--everest-sync/config/requirements.rb (renamed from everest-rebase/config/requirements.rb)0
-rw-r--r--everest-sync/lib/everest-sync.rb3
-rw-r--r--everest-sync/lib/everest-sync/core.rb (renamed from everest-rebase/lib/everest-rebase/core.rb)0
-rw-r--r--everest-sync/lib/everest-sync/version.rb (renamed from everest-rebase/lib/everest-rebase/version.rb)2
-rw-r--r--everest-sync/test/test_everest-sync.rb (renamed from everest-rebase/test/test_everest-rebase.rb)2
-rw-r--r--everest-sync/test/test_helper.rb2
15 files changed, 60 insertions, 51 deletions
diff --git a/everest-rebase/Manifest.txt b/everest-rebase/Manifest.txt
deleted file mode 100644
index 9cf18b4..0000000
--- a/everest-rebase/Manifest.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-History.txt
-Manifest.txt
-README.txt
-Rakefile
-config/hoe.rb
-config/requirements.rb
-bin/everest-rebase
-lib/everest-rebase.rb
-lib/everest-rebase/core.rb
-lib/everest-rebase/version.rb
-test/test_everest-rebase.rb
-test/test_helper.rb
diff --git a/everest-rebase/lib/everest-rebase.rb b/everest-rebase/lib/everest-rebase.rb
deleted file mode 100644
index 6b70859..0000000
--- a/everest-rebase/lib/everest-rebase.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'rubygems'
-require 'git'
-require 'everest-rebase/core'
-require 'everest-rebase/version'
diff --git a/everest-rebase/test/test_helper.rb b/everest-rebase/test/test_helper.rb
deleted file mode 100644
index 869d426..0000000
--- a/everest-rebase/test/test_helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-require 'test/unit'
-require File.dirname(__FILE__) + '/../lib/everest-rebase'
diff --git a/everest-rebase/History.txt b/everest-sync/History.txt
index b30fa6e..b30fa6e 100644
--- a/everest-rebase/History.txt
+++ b/everest-sync/History.txt
diff --git a/everest-sync/Manifest.txt b/everest-sync/Manifest.txt
new file mode 100644
index 0000000..3fe7012
--- /dev/null
+++ b/everest-sync/Manifest.txt
@@ -0,0 +1,11 @@
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+config/hoe.rb
+config/requirements.rb
+bin/everest-sync
+lib/everest-sync.rb
+lib/everest-sync/version.rb
+test/test_everest-sync.rb
+test/test_helper.rb
diff --git a/everest-rebase/README.txt b/everest-sync/README.txt
index 48d65d1..6a7d26f 100644
--- a/everest-rebase/README.txt
+++ b/everest-sync/README.txt
@@ -1,4 +1,4 @@
-= everest-rebase
+= everest-sync
* FIX (url)
@@ -45,4 +45,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/everest-rebase/Rakefile b/everest-sync/Rakefile
index 522d54e..59cb1a2 100644
--- a/everest-rebase/Rakefile
+++ b/everest-sync/Rakefile
@@ -2,12 +2,12 @@
require 'rubygems'
require 'hoe'
-require './lib/everest-rebase/version.rb'
+require './lib/everest-sync/version.rb'
-Hoe.new('everest-rebase', EverestRebase::Version::STRING) do |p|
+Hoe.new('everest-sync', EverestSync::Version::STRING) do |p|
p.author = 'it-arch'
- p.email = "gis-java@redhat.com"
- p.rubyforge_name = 'everest-bootstrap'
+ p.email = "everest-list@redhat.com"
+ p.rubyforge_name = 'everest-sync'
p.summary = 'Tool for synchronizing Everest Repo machines'
p.description = 'Tool for synchronizing Everest Repo machines'
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
diff --git a/everest-rebase/bin/everest-rebase b/everest-sync/bin/everest-sync
index 31dcbae..b745221 100644
--- a/everest-rebase/bin/everest-rebase
+++ b/everest-sync/bin/everest-sync
@@ -3,12 +3,12 @@ require 'open-uri'
require 'fileutils'
require "git"
require "main"
-require "everest-rebase"
require "highline/import"
+require "everest-sync"
#http://www.mail-archive.com/capistrano@googlegroups.com/msg01822.html
HighLine.track_eof = false
-include EverestRebase
+include EverestSync
Main {
version Version::STRING
@@ -16,7 +16,8 @@ Main {
# Normally I wouldn't use class variables but I think it's warranted within
# the 'main' DSL. If there are any other global config variables feel free
# to put them here.
- @@working_dir = File.join(ENV["HOME"], ".everest-rebase")
+ @@app_name = "everest-sync"
+ @@working_dir = File.join(ENV["HOME"], "." + @@app_name)
@@repo_path_prefix = "/pub/git"
# Main hook
@@ -72,7 +73,20 @@ Main {
repo_path = "#{@@repo_path_prefix}/#{p}"
repo_url = "git://#{@everest_repo + repo_path}"
- begin # TODO Narrow the begin scope since the rescue is so wide!
+
+ # We need to clone from the remote if the local clone doesn't exist
+ unless File.directory?(clone_dir)
+ # NOTE: For symplicity's sake I decided not to bother cloning from /pub/git
+ # locally if the repo does not exist in the working dir. This would
+ # make the tool have to detect if the local clone is out sync. While
+ # this isn't hard, I don't feel like messing with it at the moment.
+ verbose("Cloning #{repo_url} to #{clone_dir}")
+ g = Git.clone(repo_url, clone_dir)
+ g.branches.remote.each do |r|
+ next if r.name == 'HEAD'
+ checkout_b(g, r)
+ end
+ else
g = Git.open(clone_dir)
verbose "opened #{clone_dir}"
@@ -115,17 +129,6 @@ Main {
end
end
end
- rescue ArgumentError # The repo doesn't exist
- begin
- verbose("Attempting local clone from #{repo_path}")
- Git.clone(repo_path, clone_dir)
- rescue
- verbose("Couldn't find local clone. Trying remote at #{repo_url}")
- Git.clone(repo_url, clone_dir)
- end
- verbose "cloned #{p} to #{clone_dir}"
-
- # TODO: We need checkout all remote branches so they can be pushed later
end
end
end
@@ -141,7 +144,8 @@ Main {
if File.directory?(dest)
verbose("Push all branches in #{d} to #{dest}")
- Git.open(d).push(dest)
+ g = Git.open(d)
+ g.branches.local.each {|b| g.push(dest,b)}
else
verbose("Making #{bare_repo_parent_dir}")
FileUtils.mkdir_p(bare_repo_parent_dir)
@@ -163,6 +167,12 @@ Main {
def verbose(msg)
puts msg if params['verbose'].given?
end
+
+ #I couldn't find a way to 'checkout -b' so this will have to do for now
+ def checkout_b(git, branch)
+ git.branch(branch.name).checkout
+ git.reset_hard(branch)
+ end
def working_git_dirs
Dir[@@working_dir + "/**/.git"].map {|g| File.dirname(g)}
@@ -180,15 +190,14 @@ Main {
rescue Git::GitExecuteError => e
fork do
puts e.message
- puts "Type 'exit' when everything is fixed to continue 'everest-rebase'"
+ puts "Type 'exit' when everything is fixed to continue '#{@@app_name}'"
g.chdir {exec('bash')}
end
Process.wait2
end
else # We must create the branch
- g.branch(b.name).checkout
- g.reset_hard(b) #I couldn't find a way to 'checkout -b'
+ checkout_b(g,b)
end
end
@@ -198,7 +207,9 @@ Main {
# that branch they can do whatever action is contained in the 'block'--all the while
# recovering from git failures.
def git_action(g, &block)
- remote_branches = g.branches.find_all {|b| b.remote.to_s == @everest_repo}
+ remote_branches = g.branches.find_all do |b|
+ (b.remote.to_s == @everest_repo) && b.name != 'HEAD'
+ end
if remote_branches.size == 1
git_action_safe(g, remote_branches[0], &block)
diff --git a/everest-rebase/config/hoe.rb b/everest-sync/config/hoe.rb
index d119c79..2b2997d 100644
--- a/everest-rebase/config/hoe.rb
+++ b/everest-sync/config/hoe.rb
@@ -1,10 +1,10 @@
-require 'everest-rebase/version'
+require 'everest-sync/version'
AUTHOR = 'FIXME full name' # can also be an array of Authors
EMAIL = "FIXME email"
DESCRIPTION = "description of gem"
-GEM_NAME = 'everest-rebase' # what ppl will type to install your gem
-RUBYFORGE_PROJECT = 'everest-rebase' # The unix name for your project
+GEM_NAME = 'everest-sync' # what ppl will type to install your gem
+RUBYFORGE_PROJECT = 'everest-sync' # The unix name for your project
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
EXTRA_DEPENDENCIES = [
@@ -35,8 +35,8 @@ end
REV = nil
# UNCOMMENT IF REQUIRED:
# REV = YAML.load(`svn info`)['Revision']
-VERS = Everest-rebase::VERSION::STRING + (REV ? ".#{REV}" : "")
-RDOC_OPTS = ['--quiet', '--title', 'everest-rebase documentation',
+VERS = EverestSync::VERSION::STRING + (REV ? ".#{REV}" : "")
+RDOC_OPTS = ['--quiet', '--title', 'everest-sync documentation',
"--opname", "index.html",
"--line-numbers",
"--main", "README",
diff --git a/everest-rebase/config/requirements.rb b/everest-sync/config/requirements.rb
index 9292b69..9292b69 100644
--- a/everest-rebase/config/requirements.rb
+++ b/everest-sync/config/requirements.rb
diff --git a/everest-sync/lib/everest-sync.rb b/everest-sync/lib/everest-sync.rb
new file mode 100644
index 0000000..9878c75
--- /dev/null
+++ b/everest-sync/lib/everest-sync.rb
@@ -0,0 +1,3 @@
+require 'rubygems'
+require 'git'
+require 'everest-sync/version'
diff --git a/everest-rebase/lib/everest-rebase/core.rb b/everest-sync/lib/everest-sync/core.rb
index e69de29..e69de29 100644
--- a/everest-rebase/lib/everest-rebase/core.rb
+++ b/everest-sync/lib/everest-sync/core.rb
diff --git a/everest-rebase/lib/everest-rebase/version.rb b/everest-sync/lib/everest-sync/version.rb
index 9f40830..4e3a070 100644
--- a/everest-rebase/lib/everest-rebase/version.rb
+++ b/everest-sync/lib/everest-sync/version.rb
@@ -1,4 +1,4 @@
-module EverestRebase
+module EverestSync
module Version
MAJOR = 0
MINOR = 1
diff --git a/everest-rebase/test/test_everest-rebase.rb b/everest-sync/test/test_everest-sync.rb
index c97c0c9..d815cab 100644
--- a/everest-rebase/test/test_everest-rebase.rb
+++ b/everest-sync/test/test_everest-sync.rb
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/test_helper.rb'
-class TestEverest-rebase < Test::Unit::TestCase
+class TestEverestSync < Test::Unit::TestCase
def setup
end
diff --git a/everest-sync/test/test_helper.rb b/everest-sync/test/test_helper.rb
new file mode 100644
index 0000000..6bb16a7
--- /dev/null
+++ b/everest-sync/test/test_helper.rb
@@ -0,0 +1,2 @@
+require 'test/unit'
+require File.dirname(__FILE__) + '/../lib/everest-sync'