dreamcat4-braid 0.5.2 → 0.50
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/braid +2 -10
- data/braid.gemspec +2 -2
- data/lib/braid/commands/add.rb +11 -17
- data/lib/braid/commands/diff.rb +3 -10
- data/lib/braid/commands/remove.rb +10 -17
- data/lib/braid/commands/setup.rb +0 -4
- data/lib/braid/commands/update.rb +51 -56
- data/lib/braid/mirror.rb +4 -11
- data/lib/braid/operations.rb +0 -66
- metadata +1 -1
data/bin/braid
CHANGED
@@ -51,11 +51,11 @@ Main {
|
|
51
51
|
. braid add svn://remote/path --branch notmaster
|
52
52
|
TXT
|
53
53
|
|
54
|
-
mixin :argument_url, :option_type, :optional_path, :option_branch, :option_rails_plugin, :
|
54
|
+
mixin :argument_url, :option_type, :optional_path, :option_branch, :option_rails_plugin, :option_revision, :option_full, :option_verbose
|
55
55
|
|
56
56
|
run {
|
57
57
|
Braid.verbose = verbose
|
58
|
-
Braid::Command.run(:add, url, { "type" => type, "path" => path, "branch" => branch, "rails_plugin" => rails_plugin, "
|
58
|
+
Braid::Command.run(:add, url, { "type" => type, "path" => path, "branch" => branch, "rails_plugin" => rails_plugin, "revision" => revision, "full" => full })
|
59
59
|
}
|
60
60
|
}
|
61
61
|
|
@@ -196,14 +196,6 @@ Main {
|
|
196
196
|
}
|
197
197
|
}
|
198
198
|
|
199
|
-
mixin(:option_rails_gem) {
|
200
|
-
option(:rails_gem, :p) {
|
201
|
-
optional
|
202
|
-
desc 'added mirror is a Rails gem'
|
203
|
-
attr
|
204
|
-
}
|
205
|
-
}
|
206
|
-
|
207
199
|
mixin(:option_revision) {
|
208
200
|
option(:revision, :r) {
|
209
201
|
optional
|
data/braid.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{braid}
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.50"
|
4
4
|
|
5
5
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
6
6
|
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "braid", "--main"]
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
s.rubyforge_project = %q{braid}
|
20
|
-
s.rubygems_version = %q{1.
|
20
|
+
s.rubygems_version = %q{1.1.0}
|
21
21
|
s.summary = %q{A simple tool for tracking vendor branches in git.}
|
22
22
|
|
23
23
|
s.add_dependency(%q<main>, [">= 2.8.0"])
|
data/lib/braid/commands/add.rb
CHANGED
@@ -15,24 +15,18 @@ module Braid
|
|
15
15
|
# http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html
|
16
16
|
|
17
17
|
setup_remote(mirror)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
new_revision = validate_new_revision(mirror, options["revision"])
|
26
|
-
target_revision = determine_target_revision(mirror, new_revision)
|
27
|
-
|
28
|
-
unless mirror.squashed?
|
29
|
-
git.merge_ours(target_revision)
|
30
|
-
end
|
31
|
-
git.read_tree_prefix(target_revision, mirror.path)
|
32
|
-
|
33
|
-
mirror.revision = new_revision
|
34
|
-
mirror.lock = new_revision if options["revision"]
|
18
|
+
mirror.fetch
|
19
|
+
|
20
|
+
new_revision = validate_new_revision(mirror, options["revision"])
|
21
|
+
target_revision = determine_target_revision(mirror, new_revision)
|
22
|
+
|
23
|
+
unless mirror.squashed?
|
24
|
+
git.merge_ours(target_revision)
|
35
25
|
end
|
26
|
+
git.read_tree_prefix(target_revision, mirror.path)
|
27
|
+
|
28
|
+
mirror.revision = new_revision
|
29
|
+
mirror.lock = new_revision if options["revision"]
|
36
30
|
config.update(mirror)
|
37
31
|
add_config_file
|
38
32
|
|
data/lib/braid/commands/diff.rb
CHANGED
@@ -3,17 +3,10 @@ module Braid
|
|
3
3
|
class Diff < Command
|
4
4
|
def run(path)
|
5
5
|
mirror = config.get!(path)
|
6
|
-
|
7
|
-
unless system("cd #{mirror.path} && git diff")
|
8
|
-
msg "Error diffing \"#{path}\" in \"#{mirror.path}\""
|
9
|
-
exit 1
|
10
|
-
end
|
11
|
-
else
|
12
|
-
setup_remote(mirror)
|
6
|
+
setup_remote(mirror)
|
13
7
|
|
14
|
-
|
15
|
-
|
16
|
-
end
|
8
|
+
diff = mirror.diff
|
9
|
+
puts diff unless diff.empty?
|
17
10
|
end
|
18
11
|
end
|
19
12
|
end
|
@@ -9,25 +9,18 @@ module Braid
|
|
9
9
|
with_reset_on_error do
|
10
10
|
msg "Removing mirror from '#{mirror.path}'."
|
11
11
|
|
12
|
-
|
13
|
-
gitclone.remove_gitignore(mirror.path)
|
14
|
-
FileUtils.rm_rf(mirror.path)
|
15
|
-
config.remove(mirror)
|
16
|
-
add_config_file
|
17
|
-
else
|
18
|
-
git.rm_r(mirror.path)
|
12
|
+
git.rm_r(mirror.path)
|
19
13
|
|
20
|
-
|
21
|
-
|
14
|
+
config.remove(mirror)
|
15
|
+
add_config_file
|
22
16
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
17
|
+
if options[:keep]
|
18
|
+
msg "Not removing remote '#{mirror.remote}'" if verbose?
|
19
|
+
elsif git.remote_url(mirror.remote)
|
20
|
+
msg "Removed remote '#{mirror.path}'" if verbose?
|
21
|
+
git.remote_rm mirror.remote
|
22
|
+
else
|
23
|
+
msg "Remote '#{mirror.remote}' not found, nothing to cleanup" if verbose?
|
31
24
|
end
|
32
25
|
|
33
26
|
commit_message = "Removed mirror '#{mirror.path}'"
|
data/lib/braid/commands/setup.rb
CHANGED
@@ -20,78 +20,73 @@ module Braid
|
|
20
20
|
|
21
21
|
def update_one(path, options = {})
|
22
22
|
mirror = config.get!(path)
|
23
|
-
|
23
|
+
|
24
24
|
revision_message = options["revision"] ? " to #{display_revision(mirror, options["revision"])}" : ""
|
25
25
|
msg "Updating mirror '#{mirror.path}'#{revision_message}."
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
mirror.lock = nil
|
36
|
-
elsif !options["revision"]
|
37
|
-
msg "Mirror '#{mirror.path}' is locked to #{display_revision(mirror, mirror.lock)}. Use --head to force."
|
38
|
-
return
|
39
|
-
end
|
27
|
+
# check options for lock modification
|
28
|
+
if mirror.locked?
|
29
|
+
if options["head"]
|
30
|
+
msg "Unlocking mirror '#{mirror.path}'." if verbose?
|
31
|
+
mirror.lock = nil
|
32
|
+
elsif !options["revision"]
|
33
|
+
msg "Mirror '#{mirror.path}' is locked to #{display_revision(mirror, mirror.lock)}. Use --head to force."
|
34
|
+
return
|
40
35
|
end
|
36
|
+
end
|
41
37
|
|
42
|
-
|
43
|
-
|
44
|
-
|
38
|
+
setup_remote(mirror)
|
39
|
+
msg "Fetching new commits for '#{mirror.path}'." if verbose?
|
40
|
+
mirror.fetch
|
45
41
|
|
46
|
-
|
47
|
-
|
42
|
+
new_revision = validate_new_revision(mirror, options["revision"])
|
43
|
+
target_revision = determine_target_revision(mirror, new_revision)
|
48
44
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
45
|
+
if mirror.merged?(target_revision)
|
46
|
+
msg "Mirror '#{mirror.path}' is already up to date."
|
47
|
+
return
|
48
|
+
end
|
53
49
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
50
|
+
if mirror.squashed?
|
51
|
+
diff = mirror.diff
|
52
|
+
base_revision = mirror.base_revision
|
53
|
+
end
|
54
|
+
|
55
|
+
mirror.revision = new_revision
|
56
|
+
mirror.lock = new_revision if options["revision"]
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
local_hash = git.rev_parse("HEAD")
|
66
|
-
if diff
|
67
|
-
base_hash = generate_tree_hash(mirror, base_revision)
|
68
|
-
else
|
69
|
-
base_hash = local_hash
|
70
|
-
end
|
71
|
-
remote_hash = generate_tree_hash(mirror, target_revision)
|
72
|
-
ENV["GITHEAD_#{local_hash}"] = "HEAD"
|
73
|
-
ENV["GITHEAD_#{remote_hash}"] = target_revision
|
74
|
-
git.merge_recursive(base_hash, local_hash, remote_hash)
|
58
|
+
msg "Merging in mirror '#{mirror.path}'." if verbose?
|
59
|
+
begin
|
60
|
+
if mirror.squashed?
|
61
|
+
local_hash = git.rev_parse("HEAD")
|
62
|
+
if diff
|
63
|
+
base_hash = generate_tree_hash(mirror, base_revision)
|
75
64
|
else
|
76
|
-
|
65
|
+
base_hash = local_hash
|
77
66
|
end
|
78
|
-
|
79
|
-
|
67
|
+
remote_hash = generate_tree_hash(mirror, target_revision)
|
68
|
+
ENV["GITHEAD_#{local_hash}"] = "HEAD"
|
69
|
+
ENV["GITHEAD_#{remote_hash}"] = target_revision
|
70
|
+
git.merge_recursive(base_hash, local_hash, remote_hash)
|
71
|
+
else
|
72
|
+
git.merge_subtree(target_revision)
|
80
73
|
end
|
74
|
+
rescue Operations::MergeError => error
|
75
|
+
msg "Caught merge error. Breaking."
|
76
|
+
end
|
81
77
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
commit_message = "Updated mirror '#{mirror.path}' to #{display_revision(mirror)}"
|
78
|
+
config.update(mirror)
|
79
|
+
add_config_file
|
86
80
|
|
87
|
-
|
88
|
-
File.open(".git/MERGE_MSG", 'w') { |f| f.puts(commit_message) }
|
89
|
-
return
|
90
|
-
end
|
81
|
+
commit_message = "Updated mirror '#{mirror.path}' to #{display_revision(mirror)}"
|
91
82
|
|
92
|
-
|
93
|
-
|
83
|
+
if error
|
84
|
+
File.open(".git/MERGE_MSG", 'w') { |f| f.puts(commit_message) }
|
85
|
+
return
|
94
86
|
end
|
87
|
+
|
88
|
+
git.commit(commit_message)
|
89
|
+
msg commit_message
|
95
90
|
end
|
96
91
|
|
97
92
|
def generate_tree_hash(mirror, revision)
|
data/lib/braid/mirror.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
require 'rspec_git.rb'
|
2
|
-
|
3
1
|
module Braid
|
4
2
|
class Mirror
|
5
|
-
TYPES = %w(git svn
|
3
|
+
TYPES = %w(git svn)
|
6
4
|
ATTRIBUTES = %w(url remote type branch squashed revision lock)
|
7
5
|
|
8
6
|
class UnknownType < BraidError
|
@@ -23,12 +21,11 @@ module Braid
|
|
23
21
|
|
24
22
|
include Operations::VersionControl
|
25
23
|
|
26
|
-
attr_reader :path, :attributes
|
24
|
+
attr_reader :path, :attributes
|
27
25
|
|
28
26
|
def initialize(path, attributes = {})
|
29
27
|
@path = path.sub(/\/$/, '')
|
30
28
|
@attributes = attributes
|
31
|
-
@rspec_git = RSpec::Git.new File.basename(@path) @path attributes["url"]
|
32
29
|
end
|
33
30
|
|
34
31
|
def self.new_from_options(url, options = {})
|
@@ -46,14 +43,10 @@ module Braid
|
|
46
43
|
raise PathRequired
|
47
44
|
end
|
48
45
|
|
49
|
-
if options["rails_plugin"]
|
46
|
+
if options["rails_plugin"]
|
50
47
|
path = "vendor/plugins/#{path}"
|
51
48
|
end
|
52
49
|
|
53
|
-
if options["rails_gem"] && ! path =~ /vendor\/gems.*/
|
54
|
-
path = "vendor/gems/#{path}"
|
55
|
-
end
|
56
|
-
|
57
50
|
remote = "braid/#{path}".gsub("_", '-') # stupid git svn changes all _ to ., weird
|
58
51
|
squashed = !options["full"]
|
59
52
|
branch = nil if type == "svn"
|
@@ -159,7 +152,7 @@ module Braid
|
|
159
152
|
return url_scheme if TYPES.include?(url_scheme)
|
160
153
|
|
161
154
|
return "svn" if url[-6..-1] == "/trunk"
|
162
|
-
return "git
|
155
|
+
return "git" if url[-4..-1] == ".git"
|
163
156
|
end
|
164
157
|
|
165
158
|
def self.extract_path_from_url(url)
|
data/lib/braid/operations.rb
CHANGED
@@ -137,72 +137,6 @@ module Braid
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
-
class GitClone < Proxy
|
141
|
-
def in_rep_root_check
|
142
|
-
if ! File.exists?(".git")
|
143
|
-
raise("Not in root repository.")
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
def add_gitignore(path)
|
148
|
-
# add mirror to .gitignore file
|
149
|
-
in_rep_root_check
|
150
|
-
if ! File.exists?(".gitignore")
|
151
|
-
f = File.new(".gitignore", "w+")
|
152
|
-
else
|
153
|
-
f = File.open( 'index', 'w+')
|
154
|
-
end
|
155
|
-
|
156
|
-
f.each { |line|
|
157
|
-
if line == path
|
158
|
-
path_ignored = line
|
159
|
-
end
|
160
|
-
}
|
161
|
-
if ! ignored
|
162
|
-
f.puts path
|
163
|
-
git.add(".gitignore")
|
164
|
-
end
|
165
|
-
f.close
|
166
|
-
end
|
167
|
-
|
168
|
-
def remove_gitignore(path)
|
169
|
-
# remove mirror from .gitignore file
|
170
|
-
in_rep_root_check
|
171
|
-
if File.exists?(".gitignore")
|
172
|
-
f = File.open( 'index', 'w+')
|
173
|
-
|
174
|
-
f.each { |line|
|
175
|
-
if line == path
|
176
|
-
path_ignored = line
|
177
|
-
end
|
178
|
-
}
|
179
|
-
f.rewind
|
180
|
-
|
181
|
-
if path_ignored
|
182
|
-
date_str= Date.new.to_s
|
183
|
-
n = File.new(".gitignore-#{date_str}", "w+")
|
184
|
-
f.each { |line|
|
185
|
-
n.puts line unless line == path_ignored
|
186
|
-
}
|
187
|
-
n.close
|
188
|
-
end
|
189
|
-
f.close
|
190
|
-
File.rename( ".gitignore-#{date_str}", ".gitignore" )
|
191
|
-
git.add(".gitignore")
|
192
|
-
end
|
193
|
-
|
194
|
-
end
|
195
|
-
|
196
|
-
private
|
197
|
-
def command(name)
|
198
|
-
"#{self.class.command} #{name}"
|
199
|
-
end
|
200
|
-
|
201
|
-
def git
|
202
|
-
GitClone.instance
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
140
|
class Git < Proxy
|
207
141
|
def commit(message, *args)
|
208
142
|
|