braid 0.5 → 0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +1 -1
- data/bin/braid +33 -20
- data/braid.gemspec +1 -1
- data/lib/braid/commands/add.rb +2 -4
- data/lib/braid/commands/remove.rb +12 -7
- data/lib/braid/commands/update.rb +3 -4
- data/lib/braid/mirror.rb +6 -2
- data/lib/braid/operations.rb +18 -9
- data/lib/braid.rb +4 -3
- data/test/integration/adding_test.rb +2 -2
- data/test/integration/updating_test.rb +2 -2
- data/test/mirror_test.rb +1 -1
- metadata +30 -14
data/LICENSE
CHANGED
data/bin/braid
CHANGED
@@ -89,54 +89,59 @@ Main {
|
|
89
89
|
|
90
90
|
* removes metadata from .braids
|
91
91
|
* removes the local directory and commits the removal
|
92
|
-
*
|
92
|
+
* removes the git remote by default, --keep can be used to supress that
|
93
93
|
TXT
|
94
94
|
|
95
95
|
examples <<-TXT
|
96
96
|
. braid remove local/dir
|
97
97
|
TXT
|
98
98
|
|
99
|
-
mixin :argument_path, :option_verbose
|
99
|
+
mixin :argument_path, :option_verbose, :option_keep_remote
|
100
100
|
|
101
101
|
run {
|
102
|
+
options = {
|
103
|
+
:keep => keep
|
104
|
+
}
|
102
105
|
Braid.verbose = verbose
|
103
|
-
Braid::Command.run(:remove, path)
|
106
|
+
Braid::Command.run(:remove, path, options)
|
104
107
|
}
|
105
108
|
}
|
106
109
|
|
107
|
-
mode(:
|
110
|
+
mode(:diff) {
|
108
111
|
description <<-TXT
|
109
|
-
|
110
|
-
All commands that need a remote run setup internally.
|
111
|
-
|
112
|
-
Defaults to setting up remotes for all mirrors if none is specified.
|
112
|
+
Show diff of local changes to mirror.
|
113
113
|
TXT
|
114
114
|
|
115
|
-
|
116
|
-
|
115
|
+
mixin :argument_path, :option_verbose
|
116
|
+
|
117
|
+
run {
|
118
|
+
Braid::Command.run(:diff, path)
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
mode(:push) {
|
123
|
+
description <<-TXT
|
124
|
+
Push local mirror changes to remote.
|
117
125
|
TXT
|
118
126
|
|
119
|
-
mixin :
|
127
|
+
mixin :argument_path, :option_verbose
|
120
128
|
|
121
129
|
run {
|
122
130
|
Braid.verbose = verbose
|
123
|
-
Braid::Command.run(:
|
131
|
+
Braid::Command.run(:push, path)
|
124
132
|
}
|
125
133
|
}
|
126
134
|
|
127
|
-
mode(:
|
135
|
+
mode(:setup) {
|
128
136
|
description <<-TXT
|
129
|
-
|
130
|
-
TXT
|
131
|
-
|
132
|
-
examples <<-TXT
|
133
|
-
. braid diff local/dir
|
137
|
+
Set up git and git-svn remotes.
|
134
138
|
TXT
|
135
139
|
|
136
|
-
mixin :
|
140
|
+
mixin :optional_path, :option_verbose
|
137
141
|
|
138
142
|
run {
|
139
|
-
Braid
|
143
|
+
Braid.verbose = verbose
|
144
|
+
Braid::Command.run(:setup, path)
|
140
145
|
}
|
141
146
|
}
|
142
147
|
|
@@ -226,5 +231,13 @@ Main {
|
|
226
231
|
}
|
227
232
|
}
|
228
233
|
|
234
|
+
mixin(:option_keep_remote) {
|
235
|
+
option(:keep) {
|
236
|
+
optional
|
237
|
+
desc 'do not remove the remote'
|
238
|
+
attr
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
229
242
|
run { help! }
|
230
243
|
}
|
data/braid.gemspec
CHANGED
data/lib/braid/commands/add.rb
CHANGED
@@ -30,10 +30,8 @@ module Braid
|
|
30
30
|
config.update(mirror)
|
31
31
|
add_config_file
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
git.commit(commit_message)
|
36
|
-
msg commit_message
|
33
|
+
git.commit("Add mirror '#{mirror.path}' at #{display_revision(mirror)}")
|
34
|
+
msg "Added mirror at #{display_revision(mirror)}."
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Braid
|
2
2
|
module Commands
|
3
3
|
class Remove < Command
|
4
|
-
def run(path)
|
4
|
+
def run(path, options = {})
|
5
5
|
mirror = config.get!(path)
|
6
6
|
|
7
7
|
bail_on_local_changes!
|
@@ -11,15 +11,20 @@ module Braid
|
|
11
11
|
|
12
12
|
git.rm_r(mirror.path)
|
13
13
|
|
14
|
-
# will need this in case we decide to remove the .git/config entry also
|
15
|
-
# setup_remote(mirror)
|
16
|
-
|
17
14
|
config.remove(mirror)
|
18
15
|
add_config_file
|
19
16
|
|
20
|
-
|
21
|
-
|
22
|
-
|
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?
|
24
|
+
end
|
25
|
+
|
26
|
+
git.commit("Remove mirror '#{mirror.path}'")
|
27
|
+
msg "Removed mirror." if verbose?
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
@@ -59,7 +59,7 @@ module Braid
|
|
59
59
|
begin
|
60
60
|
if mirror.squashed?
|
61
61
|
local_hash = git.rev_parse("HEAD")
|
62
|
-
if diff
|
62
|
+
if !diff.empty?
|
63
63
|
base_hash = generate_tree_hash(mirror, base_revision)
|
64
64
|
else
|
65
65
|
base_hash = local_hash
|
@@ -78,15 +78,14 @@ module Braid
|
|
78
78
|
config.update(mirror)
|
79
79
|
add_config_file
|
80
80
|
|
81
|
-
commit_message = "
|
82
|
-
|
81
|
+
commit_message = "Update mirror '#{mirror.path}' to #{display_revision(mirror)}"
|
83
82
|
if error
|
84
83
|
File.open(".git/MERGE_MSG", 'w') { |f| f.puts(commit_message) }
|
85
84
|
return
|
86
85
|
end
|
87
86
|
|
88
87
|
git.commit(commit_message)
|
89
|
-
msg
|
88
|
+
msg "Updated mirror to #{display_revision(mirror)}."
|
90
89
|
end
|
91
90
|
|
92
91
|
def generate_tree_hash(mirror, revision)
|
data/lib/braid/mirror.rb
CHANGED
@@ -86,7 +86,7 @@ module Braid
|
|
86
86
|
def diff
|
87
87
|
remote_hash = git.rev_parse("#{base_revision}:")
|
88
88
|
local_hash = git.tree_hash(path)
|
89
|
-
remote_hash != local_hash ? git.diff_tree(remote_hash, local_hash
|
89
|
+
remote_hash != local_hash ? git.diff_tree(remote_hash, local_hash) : ""
|
90
90
|
end
|
91
91
|
|
92
92
|
def fetch
|
@@ -99,7 +99,7 @@ module Braid
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def cached?
|
102
|
-
git.remote_url(remote) ==
|
102
|
+
git.remote_url(remote) == cached_url
|
103
103
|
end
|
104
104
|
|
105
105
|
def base_revision
|
@@ -114,6 +114,10 @@ module Braid
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
+
def cached_url
|
118
|
+
git_cache.path(url)
|
119
|
+
end
|
120
|
+
|
117
121
|
private
|
118
122
|
def method_missing(name, *args)
|
119
123
|
if ATTRIBUTES.find { |attribute| name.to_s =~ /^(#{attribute})(=)?$/ }
|
data/lib/braid/operations.rb
CHANGED
@@ -139,12 +139,16 @@ module Braid
|
|
139
139
|
|
140
140
|
class Git < Proxy
|
141
141
|
def commit(message, *args)
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
142
|
+
cmd = "git commit --no-verify"
|
143
|
+
if message # allow nil
|
144
|
+
message_file = Tempfile.new("braid_commit")
|
145
|
+
message_file.print("Braid: #{message}")
|
146
|
+
message_file.flush
|
147
|
+
cmd << " -F #{message_file.path}"
|
148
|
+
end
|
149
|
+
cmd << " #{args.join(' ')}" unless args.empty?
|
150
|
+
status, out, err = exec(cmd)
|
151
|
+
message_file.unlink if message_file
|
148
152
|
|
149
153
|
if status == 0
|
150
154
|
true
|
@@ -155,10 +159,10 @@ module Braid
|
|
155
159
|
end
|
156
160
|
end
|
157
161
|
|
158
|
-
def fetch(remote = nil)
|
159
|
-
args
|
162
|
+
def fetch(remote = nil, *args)
|
163
|
+
args.unshift "-n #{remote}" if remote
|
160
164
|
# open4 messes with the pipes of index-pack
|
161
|
-
sh("git fetch #{args} 2>&1 >/dev/null")
|
165
|
+
sh("git fetch #{args.join(' ')} 2>&1 >/dev/null")
|
162
166
|
end
|
163
167
|
|
164
168
|
def checkout(treeish)
|
@@ -185,6 +189,11 @@ module Braid
|
|
185
189
|
true
|
186
190
|
end
|
187
191
|
|
192
|
+
def remote_rm(remote)
|
193
|
+
invoke(:remote, "rm", remote)
|
194
|
+
true
|
195
|
+
end
|
196
|
+
|
188
197
|
# Checks git and svn remotes.
|
189
198
|
def remote_url(remote)
|
190
199
|
key = "remote.#{remote}.url"
|
data/lib/braid.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
$:.unshift File.dirname(__FILE__)
|
1
|
+
$:.unshift dirname = File.dirname(__FILE__)
|
2
2
|
|
3
3
|
module Braid
|
4
|
-
VERSION = "0.
|
4
|
+
VERSION = "0.6"
|
5
5
|
|
6
6
|
CONFIG_FILE = ".braids"
|
7
7
|
REQUIRED_GIT_VERSION = "1.6"
|
@@ -20,10 +20,11 @@ module Braid
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
require dirname + '/core_ext'
|
23
24
|
require 'braid/operations'
|
24
25
|
require 'braid/mirror'
|
25
26
|
require 'braid/config'
|
26
27
|
require 'braid/command'
|
27
|
-
Dir[
|
28
|
+
Dir[dirname + '/braid/commands/*'].each do |file|
|
28
29
|
require file
|
29
30
|
end
|
@@ -24,7 +24,7 @@ describe "Adding a mirror in a clean repository" do
|
|
24
24
|
|
25
25
|
output = `git log --pretty=oneline`.split("\n")
|
26
26
|
output.length.should == 2
|
27
|
-
output[0].should =~ /Braid:
|
27
|
+
output[0].should =~ /Braid: Add mirror 'skit1' at '[0-9a-f]{7}'/
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should create .braids and add the mirror to it" do
|
@@ -59,7 +59,7 @@ describe "Adding a mirror in a clean repository" do
|
|
59
59
|
|
60
60
|
output = `git log --pretty=oneline`.split("\n")
|
61
61
|
output.length.should == 2
|
62
|
-
output[0].should =~ /Braid:
|
62
|
+
output[0].should =~ /Braid: Add mirror 'skit1' at r1/
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should create .braids and add the mirror to it" do
|
@@ -41,7 +41,7 @@ describe "Updating a mirror without conflicts" do
|
|
41
41
|
|
42
42
|
output = `git log --pretty=oneline`.split("\n")
|
43
43
|
output.length.should == 3
|
44
|
-
output[0].should =~ /Braid:
|
44
|
+
output[0].should =~ /Braid: Update mirror 'skit1' to '[0-9a-f]{7}'/
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
@@ -79,7 +79,7 @@ describe "Updating a mirror without conflicts" do
|
|
79
79
|
|
80
80
|
output = `git log --pretty=oneline`.split("\n")
|
81
81
|
output.length.should == 3
|
82
|
-
output[0].should =~ /Braid:
|
82
|
+
output[0].should =~ /Braid: Update mirror 'skit1' to r3/
|
83
83
|
end
|
84
84
|
|
85
85
|
end
|
data/test/mirror_test.rb
CHANGED
@@ -61,7 +61,7 @@ describe "Braid::Mirror#diff" do
|
|
61
61
|
it "should generate a diff when the hashes do not match" do
|
62
62
|
set_hashes('b' * 40, 'c' * 40)
|
63
63
|
diff = "diff --git a/path b/path\n"
|
64
|
-
git.expects(:diff_tree).with('b' * 40, 'c' * 40
|
64
|
+
git.expects(:diff_tree).with('b' * 40, 'c' * 40).returns(diff)
|
65
65
|
@mirror.diff.should == diff
|
66
66
|
end
|
67
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: braid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 6
|
8
|
+
version: "0.6"
|
5
9
|
platform: ruby
|
6
10
|
authors:
|
7
11
|
- Cristi Balan
|
@@ -10,29 +14,37 @@ autorequire:
|
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
16
|
|
13
|
-
date: 2008-10-29 00:00:00 +
|
17
|
+
date: 2008-10-29 00:00:00 +01:00
|
14
18
|
default_executable: braid
|
15
19
|
dependencies:
|
16
20
|
- !ruby/object:Gem::Dependency
|
17
21
|
name: main
|
18
|
-
|
19
|
-
|
20
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
21
24
|
requirements:
|
22
25
|
- - ">="
|
23
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 8
|
30
|
+
- 0
|
24
31
|
version: 2.8.0
|
25
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
26
34
|
- !ruby/object:Gem::Dependency
|
27
35
|
name: open4
|
28
|
-
|
29
|
-
|
30
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
38
|
requirements:
|
32
39
|
- - ">="
|
33
40
|
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
- 9
|
44
|
+
- 6
|
34
45
|
version: 0.9.6
|
35
|
-
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
36
48
|
description: A simple tool for tracking vendor branches in git.
|
37
49
|
email: evil@che.lu
|
38
50
|
executables:
|
@@ -70,8 +82,10 @@ files:
|
|
70
82
|
- test/mirror_test.rb
|
71
83
|
- test/operations_test.rb
|
72
84
|
- test/test_helper.rb
|
73
|
-
has_rdoc:
|
85
|
+
has_rdoc: true
|
74
86
|
homepage: http://evil.che.lu/projects/braid
|
87
|
+
licenses: []
|
88
|
+
|
75
89
|
post_install_message:
|
76
90
|
rdoc_options:
|
77
91
|
- --line-numbers
|
@@ -85,18 +99,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
99
|
requirements:
|
86
100
|
- - ">="
|
87
101
|
- !ruby/object:Gem::Version
|
102
|
+
segments:
|
103
|
+
- 0
|
88
104
|
version: "0"
|
89
|
-
version:
|
90
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
106
|
requirements:
|
92
107
|
- - ">="
|
93
108
|
- !ruby/object:Gem::Version
|
109
|
+
segments:
|
110
|
+
- 0
|
94
111
|
version: "0"
|
95
|
-
version:
|
96
112
|
requirements: []
|
97
113
|
|
98
114
|
rubyforge_project: braid
|
99
|
-
rubygems_version: 1.
|
115
|
+
rubygems_version: 1.3.6
|
100
116
|
signing_key:
|
101
117
|
specification_version: 2
|
102
118
|
summary: A simple tool for tracking vendor branches in git.
|