diff --git a/bin/braid b/bin/braid index cafc8a3..283faa7 100755 --- a/bin/braid +++ b/bin/braid @@ -75,11 +75,11 @@ Main { . braid update local/dir TXT - mixin :optional_path, :option_revision, :option_head, :option_verbose + mixin :optional_path, :option_branch, :option_revision, :option_head, :option_verbose run { Braid.verbose = verbose - Braid::Command.run(:update, path, { "revision" => revision, "head" => head }) + Braid::Command.run(:update, path, { "branch" => branch, "revision" => revision, "head" => head }) } } diff --git a/braid.gemspec b/braid.gemspec index 24daf68..90b0f95 100644 --- a/braid.gemspec +++ b/braid.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = %q{braid} - s.version = "0.531" + s.version = "0.532" s.specification_version = 2 if s.respond_to? :specification_version= diff --git a/lib/braid.rb b/lib/braid.rb index 31e48d4..6e5eac9 100644 --- a/lib/braid.rb +++ b/lib/braid.rb @@ -3,7 +3,9 @@ module Braid VERSION = "0.5" - CONFIG_FILE = ".braids" + # CONFIG_FILE = ".braids" + # CONFIG_FILE = "CONFIGFILE" + CONFIG_FILE = ".gitnest" REQUIRED_GIT_VERSION = "1.6" def self.verbose; @verbose || false; end diff --git a/lib/braid/commands/add.rb b/lib/braid/commands/add.rb index 16353ba..3dbad2d 100644 --- a/lib/braid/commands/add.rb +++ b/lib/braid/commands/add.rb @@ -18,7 +18,7 @@ def run(url, options = {}) if mirror.type == "git-clone" gitclone.add_gitignore(mirror.path) - mirror.rspec_git.update options["revision"] + mirror.rspec_git.update mirror.branch commit_message = "Added clone repository #{mirror.rspec_git.url} in #{mirror.path}" else mirror.fetch diff --git a/lib/braid/commands/update.rb b/lib/braid/commands/update.rb index 925e9a9..e9d1636 100644 --- a/lib/braid/commands/update.rb +++ b/lib/braid/commands/update.rb @@ -25,7 +25,12 @@ def update_one(path, options = {}) msg "Updating mirror '#{mirror.path}'#{revision_message}." if mirror.type == "git-clone" - mirror.rspec_git.update options["revision"] + mirror.branch = options["branch"] || mirror.branch + # config.update(mirror) + mirror.rspec_git.update mirror.branch + config.update(mirror) + add_config_file + commit_message = "Updated clone repository '#{mirror.path}' to #{mirror.branch}" else # check options for lock modification @@ -88,10 +93,10 @@ def update_one(path, options = {}) File.open(".git/MERGE_MSG", 'w') { |f| f.puts(commit_message) } return end - - git.commit(commit_message) - msg commit_message end + + git.commit(commit_message) + msg commit_message end def generate_tree_hash(mirror, revision) diff --git a/lib/braid/config.rb b/lib/braid/config.rb index c3e9a70..e6e34d0 100644 --- a/lib/braid/config.rb +++ b/lib/braid/config.rb @@ -1,6 +1,20 @@ require 'yaml' require 'yaml/store' +class Hash + # Replacing the to_yaml function so it'll serialize hashes sorted (by their keys) + # Original function is in /usr/lib/ruby/1.8/yaml/rubytypes.rb + def to_yaml( opts = {} ) + YAML::quick_emit( object_id, opts ) do |out| + out.map( taguri, to_yaml_style ) do |map| + sort.each do |k, v| # <-- here's my addition (the 'sort') + map.add( k, v ) + end + end + end + end +end + module Braid class Config class PathAlreadyInUse < BraidError diff --git a/lib/braid/mirror.rb b/lib/braid/mirror.rb index 64b6f27..36c6328 100644 --- a/lib/braid/mirror.rb +++ b/lib/braid/mirror.rb @@ -2,7 +2,7 @@ require 'rspec_git.rb' module Braid - class Mirror + class Mirror TYPES = %w(git svn git-clone) ATTRIBUTES = %w(url remote type branch squashed revision lock) @@ -37,11 +37,11 @@ def self.new_from_options(url, options = {}) branch = options["branch"] || "master" - if type = options["type"] || extract_type_from_url(url) - raise UnknownType, type unless TYPES.include?(type) - else - raise CannotGuessType, url - end + # if type = options["type"] || extract_type_from_url(url) + # raise UnknownType, type unless TYPES.include?(type) + # else + # raise CannotGuessType, url + # end unless path = options["path"] || extract_path_from_url(url) raise PathRequired @@ -55,33 +55,43 @@ def self.new_from_options(url, options = {}) path = "vendor/gems/#{path}" end - if type != "git-clone" - remote = "braid/#{path}".gsub("_", '-') # stupid git svn changes all _ to ., weird - squashed = !options["full"] - branch = nil if type == "svn" - end + # if type != "git-clone" + # remote = "braid/#{path}".gsub("_", '-') # stupid git svn changes all _ to ., weird + # squashed = !options["full"] + # branch = nil if type == "svn" + # end - attributes = { "url" => url, "remote" => remote, "type" => type, "branch" => branch, "squashed" => squashed } + # attributes = { "url" => url, "remote" => remote, "type" => type, "branch" => branch, "squashed" => squashed } + attributes = { "url" => url, "branch" => branch } self.new(path, attributes) end - + def ==(comparison) path == comparison.path && attributes == comparison.attributes end def type # override Object#type - attributes["type"] + # attributes["type"] + return "git-clone" end def locked? !!lock end + # def squashed? + # !!squashed + # end + def squashed? - !!squashed + return true end + def remote + return "braid/#{path}" + end + def merged?(commit) # tip from spearce in #git: # `test z$(git merge-base A B) = z$(git rev-parse --verify A)` diff --git a/lib/braid/rspec_git.rb b/lib/braid/rspec_git.rb index 4fd5cd9..b0f1030 100644 --- a/lib/braid/rspec_git.rb +++ b/lib/braid/rspec_git.rb @@ -31,7 +31,10 @@ def update(target) end else msg "** Fetching #{r[:name]}" - system "git clone #{r[:url]} #{r[:path]}" + unless system "git clone #{r[:url]} #{r[:path]}" + msg "Error cloning #{r[:url]}" + exit 1 + end end end msg "*** all repos updated successfully ***"