Skip to content

Commit

Permalink
More fixes to gitnest - hack.
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamcat4 committed Apr 25, 2009
1 parent aaa920c commit 2bb5512
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 25 deletions.
4 changes: 2 additions & 2 deletions bin/braid
Expand Up @@ -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 })
}
}

Expand Down
2 changes: 1 addition & 1 deletion 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=

Expand Down
4 changes: 3 additions & 1 deletion lib/braid.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/braid/commands/add.rb
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions lib/braid/commands/update.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions 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
Expand Down
40 changes: 25 additions & 15 deletions lib/braid/mirror.rb
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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)`
Expand Down
5 changes: 4 additions & 1 deletion lib/braid/rspec_git.rb
Expand Up @@ -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 ***"
Expand Down

0 comments on commit 2bb5512

Please sign in to comment.