mlightner-braid 0.5.1
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 +20 -0
- data/README.textile +120 -0
- data/Rakefile +17 -0
- data/bin/braid +249 -0
- data/braid.gemspec +25 -0
- data/lib/braid.rb +29 -0
- data/lib/braid/command.rb +131 -0
- data/lib/braid/commands/add.rb +42 -0
- data/lib/braid/commands/diff.rb +13 -0
- data/lib/braid/commands/list.rb +32 -0
- data/lib/braid/commands/remove.rb +33 -0
- data/lib/braid/commands/setup.rb +34 -0
- data/lib/braid/commands/update.rb +102 -0
- data/lib/braid/config.rb +101 -0
- data/lib/braid/mirror.rb +173 -0
- data/lib/braid/operations.rb +390 -0
- data/test/braid_test.rb +7 -0
- data/test/config_test.rb +62 -0
- data/test/fixtures/shiny/README +3 -0
- data/test/fixtures/skit1.1/layouts/layout.liquid +219 -0
- data/test/fixtures/skit1.2/layouts/layout.liquid +221 -0
- data/test/fixtures/skit1/layouts/layout.liquid +219 -0
- data/test/fixtures/skit1/preview.png +0 -0
- data/test/integration/adding_test.rb +80 -0
- data/test/integration/updating_test.rb +87 -0
- data/test/integration_helper.rb +70 -0
- data/test/mirror_test.rb +110 -0
- data/test/operations_test.rb +66 -0
- data/test/test_helper.rb +15 -0
- metadata +103 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2007-2008 Cristi Balan, Norbert Crombach
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
h1. Braid
|
2
|
+
|
3
|
+
Braid is a simple tool to help track git and svn vendor branches in a git repository.
|
4
|
+
|
5
|
+
The project homepage is at "http://github.com/evilchelu/braid/wikis/home":http://github.com/evilchelu/braid/wikis/home
|
6
|
+
|
7
|
+
h2. Requirements
|
8
|
+
|
9
|
+
* git 1.6+ (and git-svn if you want to mirror svn repositories)
|
10
|
+
* main >= 2.8.0
|
11
|
+
* open4 >= 0.9.6
|
12
|
+
|
13
|
+
h2. Installing using rubygems - official releases
|
14
|
+
|
15
|
+
gem install braid
|
16
|
+
|
17
|
+
h2. Installing using rubygems - development releases
|
18
|
+
|
19
|
+
gem sources -a http://gems.github.com
|
20
|
+
gem install evilchelu-braid
|
21
|
+
|
22
|
+
h2. Installing from source
|
23
|
+
|
24
|
+
git clone git://github.com/evilchelu/braid.git
|
25
|
+
cd braid
|
26
|
+
gem build braid.gemspec
|
27
|
+
sudo gem install braid-x.y.z.gem
|
28
|
+
|
29
|
+
h2. Quick usage - ruby project
|
30
|
+
|
31
|
+
Let's assume we're writing something like gitnub that needs grit in lib/grit. Initialize the repo (nothing braid related here):
|
32
|
+
|
33
|
+
git init gritty
|
34
|
+
cd gritty
|
35
|
+
touch README
|
36
|
+
git add README
|
37
|
+
git commit -m "initial commit"
|
38
|
+
|
39
|
+
Now let's vendor grit:
|
40
|
+
|
41
|
+
braid add git://github.com/mojombo/grit.git lib/grit
|
42
|
+
|
43
|
+
And you're done! Braid vendored grit into lib/grit. Feel free to inspect the changes with git log or git show.
|
44
|
+
|
45
|
+
If further down the line, you want to bring new changes from grit in your repository, just update the mirror:
|
46
|
+
|
47
|
+
braid update lib/grit
|
48
|
+
|
49
|
+
h2. Quick usage - rails project
|
50
|
+
|
51
|
+
Let's assume you want to start a new rails app called shiny. Initialize the repo (nothing braid related here):
|
52
|
+
|
53
|
+
git init shiny
|
54
|
+
cd shiny
|
55
|
+
touch README
|
56
|
+
git add README
|
57
|
+
git commit -m "initial commit"
|
58
|
+
|
59
|
+
Vendor rails (this might take a while because the rails repo is huge!):
|
60
|
+
|
61
|
+
braid add git://github.com/rails/rails.git vendor/rails
|
62
|
+
|
63
|
+
Create your new rails app (nothing braid related here):
|
64
|
+
|
65
|
+
ruby vendor/rails/railties/bin/rails .
|
66
|
+
git add .
|
67
|
+
git commit -m "rails ."
|
68
|
+
|
69
|
+
Add any plugins you might need:
|
70
|
+
|
71
|
+
braid add git://github.com/thoughtbot/shoulda.git -p
|
72
|
+
braid add git://github.com/thoughtbot/factory_girl.git -p
|
73
|
+
braid add git://github.com/mbleigh/subdomain-fu.git -p
|
74
|
+
|
75
|
+
And you're done! Braid vendored rails and your plugins. Feel free to inspect the changes with git log or git show.
|
76
|
+
|
77
|
+
If further down the line, you want to bring new changes from rails in your repository, just update the mirror:
|
78
|
+
|
79
|
+
braid update vendor/rails
|
80
|
+
|
81
|
+
Or, if you want all mirrors updated:
|
82
|
+
|
83
|
+
braid update
|
84
|
+
|
85
|
+
h2. More usage
|
86
|
+
|
87
|
+
Use the built in help system to find out about all commands and options:
|
88
|
+
|
89
|
+
braid help
|
90
|
+
braid help add # or braid add --help
|
91
|
+
|
92
|
+
You may also want to read "Usage and examples":http://github.com/evilchelu/braid/wikis/usage-and-examples.
|
93
|
+
|
94
|
+
h2. Troubleshooting
|
95
|
+
|
96
|
+
Check "Troubleshooting":http://github.com/evilchelu/braid/wikis/troubleshooting if you're having issues.
|
97
|
+
|
98
|
+
h2. Contributing
|
99
|
+
|
100
|
+
We appreciate any patches, error reports and usage ideas you may have. Please submit a lighthouse ticket or start a thread on the mailing list.
|
101
|
+
|
102
|
+
Bugs and feature requests: "*braid project on lighthouse*":http://evilchelu.lighthouseapp.com/projects/10600-braid
|
103
|
+
|
104
|
+
Discussions and community support: "*braid-gem google group*":http://groups.google.com/group/braid-gem
|
105
|
+
|
106
|
+
h2. Authors
|
107
|
+
|
108
|
+
* Cristi Balan (evilchelu)
|
109
|
+
* Norbert Crombach (norbert)
|
110
|
+
|
111
|
+
h2. Contributors (alphabetically)
|
112
|
+
|
113
|
+
* Alan Harper
|
114
|
+
* Christoph Sturm
|
115
|
+
* Dennis Muhlestein
|
116
|
+
* Ferdinand Svehla
|
117
|
+
* Michael Klishin
|
118
|
+
* Roman Heinrich
|
119
|
+
* Tyler Rick
|
120
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
task :default => :test
|
5
|
+
|
6
|
+
def test_task(name, pattern)
|
7
|
+
Rake::TestTask.new(name) do |t|
|
8
|
+
ENV['TESTOPTS'] = '--runner=s'
|
9
|
+
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.pattern = pattern
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
test_task(:test, "test/*_test.rb")
|
17
|
+
namespace(:test) { test_task(:integration, "test/integration/*_test.rb") }
|
data/bin/braid
ADDED
@@ -0,0 +1,249 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
4
|
+
require 'braid'
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'main'
|
8
|
+
|
9
|
+
Home = File.expand_path(ENV['HOME'] || '~')
|
10
|
+
|
11
|
+
# mostly blantantly stolen from ara's punch script
|
12
|
+
# main kicks ass!
|
13
|
+
Main {
|
14
|
+
description <<-TXT
|
15
|
+
braid is a simple tool to help track git or svn repositories inside a git repository.
|
16
|
+
|
17
|
+
Run 'braid help commandname' for more details.
|
18
|
+
|
19
|
+
All operations will be executed in the braid/track branch.
|
20
|
+
You can then merge back or cherry-pick changes.
|
21
|
+
TXT
|
22
|
+
|
23
|
+
mode(:add) {
|
24
|
+
description <<-TXT
|
25
|
+
Add a new mirror to be tracked.
|
26
|
+
|
27
|
+
* adds metadata about the mirror to .braids
|
28
|
+
* adds the git or git svn remotes to .git/config
|
29
|
+
* fetches and merges remote code into given directory
|
30
|
+
|
31
|
+
--type defaults:
|
32
|
+
|
33
|
+
* svn://path # => svn
|
34
|
+
* git://path # => git
|
35
|
+
* http://path/trunk # => svn
|
36
|
+
* http://path.git # => git
|
37
|
+
|
38
|
+
Name defaults:
|
39
|
+
|
40
|
+
* remote/path # => path
|
41
|
+
* remote/path/trunk # => path
|
42
|
+
* remote/path.git # => path
|
43
|
+
TXT
|
44
|
+
|
45
|
+
examples <<-TXT
|
46
|
+
. braid add svn://remote/path
|
47
|
+
. braid add svn://remote/path local/dir
|
48
|
+
. braid add git://remote/path local/dir
|
49
|
+
. braid add http://remote/path.git local/dir
|
50
|
+
. braid add http://remote/path --type git local/dir
|
51
|
+
. braid add svn://remote/path --branch notmaster
|
52
|
+
TXT
|
53
|
+
|
54
|
+
mixin :argument_url, :option_type, :optional_path, :option_branch, :option_rails_plugin, :option_revision, :option_full, :option_verbose
|
55
|
+
|
56
|
+
run {
|
57
|
+
Braid.verbose = verbose
|
58
|
+
Braid::Command.run(:add, url, { "type" => type, "path" => path, "branch" => branch, "rails_plugin" => rails_plugin, "revision" => revision, "full" => full })
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
mode(:update) {
|
63
|
+
description <<-TXT
|
64
|
+
Update a braid mirror.
|
65
|
+
|
66
|
+
* get new changes from remote
|
67
|
+
* always creates a merge commit
|
68
|
+
* updates metadata in .braids when revisions are changed
|
69
|
+
|
70
|
+
Defaults to updating all unlocked mirrors if none is specified.
|
71
|
+
TXT
|
72
|
+
|
73
|
+
examples <<-TXT
|
74
|
+
. braid update
|
75
|
+
. braid update local/dir
|
76
|
+
TXT
|
77
|
+
|
78
|
+
mixin :optional_path, :option_revision, :option_head, :option_verbose
|
79
|
+
|
80
|
+
run {
|
81
|
+
Braid.verbose = verbose
|
82
|
+
Braid::Command.run(:update, path, { "revision" => revision, "head" => head })
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
mode(:remove) {
|
87
|
+
description <<-TXT
|
88
|
+
Remove a mirror.
|
89
|
+
|
90
|
+
* removes metadata from .braids
|
91
|
+
* removes the local directory and commits the removal
|
92
|
+
* removes the git remote by default, --keep can be used to supress that
|
93
|
+
TXT
|
94
|
+
|
95
|
+
examples <<-TXT
|
96
|
+
. braid remove local/dir
|
97
|
+
TXT
|
98
|
+
|
99
|
+
mixin :argument_path, :option_verbose, :option_keep_remote
|
100
|
+
|
101
|
+
run {
|
102
|
+
options = {
|
103
|
+
:keep => keep
|
104
|
+
}
|
105
|
+
Braid.verbose = verbose
|
106
|
+
Braid::Command.run(:remove, path, options)
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
mode(:setup) {
|
111
|
+
description <<-TXT
|
112
|
+
Set up git or git-svn remote for a mirror.
|
113
|
+
All commands that need a remote run setup internally.
|
114
|
+
|
115
|
+
Defaults to setting up remotes for all mirrors if none is specified.
|
116
|
+
TXT
|
117
|
+
|
118
|
+
examples <<-TXT
|
119
|
+
. braid setup local/dir
|
120
|
+
TXT
|
121
|
+
|
122
|
+
mixin :optional_path, :option_verbose
|
123
|
+
|
124
|
+
run {
|
125
|
+
Braid.verbose = verbose
|
126
|
+
Braid::Command.run(:setup, path)
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
mode(:diff) {
|
131
|
+
description <<-TXT
|
132
|
+
Show diff of local changes to mirror.
|
133
|
+
TXT
|
134
|
+
|
135
|
+
examples <<-TXT
|
136
|
+
. braid diff local/dir
|
137
|
+
TXT
|
138
|
+
|
139
|
+
mixin :argument_path, :option_verbose
|
140
|
+
|
141
|
+
run {
|
142
|
+
Braid::Command.run(:diff, path)
|
143
|
+
}
|
144
|
+
}
|
145
|
+
|
146
|
+
mode(:version) {
|
147
|
+
description 'Show braid version.'
|
148
|
+
|
149
|
+
run {
|
150
|
+
puts "braid #{Braid::VERSION}"
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
mode(:list) {
|
155
|
+
description 'Show all tracked mirrors (and if updates are available).'
|
156
|
+
|
157
|
+
run {
|
158
|
+
Braid::Command.run(:list)
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
mixin(:argument_path) {
|
163
|
+
argument(:path) {
|
164
|
+
attr
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
mixin(:optional_path) {
|
169
|
+
argument(:path) {
|
170
|
+
optional
|
171
|
+
attr
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
mixin(:argument_url) {
|
176
|
+
argument(:url) {
|
177
|
+
attr
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
mixin(:option_type) {
|
182
|
+
option(:type, :t) {
|
183
|
+
optional
|
184
|
+
argument :required
|
185
|
+
desc 'mirror type'
|
186
|
+
attr
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
mixin(:option_branch) {
|
191
|
+
option(:branch, :b) {
|
192
|
+
optional
|
193
|
+
argument :required
|
194
|
+
desc 'remote branch name'
|
195
|
+
attr
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
mixin(:option_rails_plugin) {
|
200
|
+
option(:rails_plugin, :p) {
|
201
|
+
optional
|
202
|
+
desc 'added mirror is a Rails plugin'
|
203
|
+
attr
|
204
|
+
}
|
205
|
+
}
|
206
|
+
|
207
|
+
mixin(:option_revision) {
|
208
|
+
option(:revision, :r) {
|
209
|
+
optional
|
210
|
+
argument :required
|
211
|
+
desc 'revision to track'
|
212
|
+
attr
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
mixin(:option_head) {
|
217
|
+
option(:head) {
|
218
|
+
optional
|
219
|
+
desc 'mirror head'
|
220
|
+
attr
|
221
|
+
}
|
222
|
+
}
|
223
|
+
|
224
|
+
mixin(:option_full) {
|
225
|
+
option(:full) {
|
226
|
+
optional
|
227
|
+
desc 'include mirror history' # FIXME
|
228
|
+
attr
|
229
|
+
}
|
230
|
+
}
|
231
|
+
|
232
|
+
mixin(:option_verbose) {
|
233
|
+
option(:verbose, :v) {
|
234
|
+
optional
|
235
|
+
desc 'log shell commands'
|
236
|
+
attr
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
mixin(:option_keep_remote) {
|
241
|
+
option(:keep) {
|
242
|
+
optional
|
243
|
+
desc 'do not remove the remote'
|
244
|
+
attr
|
245
|
+
}
|
246
|
+
}
|
247
|
+
|
248
|
+
run { help! }
|
249
|
+
}
|
data/braid.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{braid}
|
3
|
+
s.version = "0.5.1"
|
4
|
+
|
5
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Cristi Balan", "Norbert Crombach"]
|
9
|
+
s.date = %q{2008-10-29}
|
10
|
+
s.default_executable = %q{braid}
|
11
|
+
s.description = %q{A simple tool for tracking vendor branches in git.}
|
12
|
+
s.email = %q{evil@che.lu}
|
13
|
+
s.executables = ["braid"]
|
14
|
+
s.files = ["bin/braid", "braid.gemspec", "lib/braid/command.rb", "lib/braid/commands/list.rb", "lib/braid/commands/add.rb", "lib/braid/commands/diff.rb", "lib/braid/commands/remove.rb", "lib/braid/commands/setup.rb", "lib/braid/commands/update.rb", "lib/braid/config.rb", "lib/braid/mirror.rb", "lib/braid/operations.rb", "lib/braid.rb", "LICENSE", "Rakefile", "README.textile", "test/braid_test.rb", "test/config_test.rb", "test/fixtures/shiny/README", "test/fixtures/skit1/layouts/layout.liquid", "test/fixtures/skit1/preview.png", "test/fixtures/skit1.1/layouts/layout.liquid", "test/fixtures/skit1.2/layouts/layout.liquid", "test/integration/adding_test.rb", "test/integration/updating_test.rb", "test/integration_helper.rb", "test/mirror_test.rb", "test/operations_test.rb", "test/test_helper.rb"]
|
15
|
+
s.has_rdoc = false
|
16
|
+
s.homepage = %q{http://evil.che.lu/projects/braid}
|
17
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "braid", "--main"]
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
s.rubyforge_project = %q{braid}
|
20
|
+
s.rubygems_version = %q{1.1.0}
|
21
|
+
s.summary = %q{A simple tool for tracking vendor branches in git.}
|
22
|
+
|
23
|
+
s.add_dependency(%q<main>, [">= 2.8.0"])
|
24
|
+
s.add_dependency(%q<open4>, [">= 0.9.6"])
|
25
|
+
end
|
data/lib/braid.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
|
3
|
+
module Braid
|
4
|
+
VERSION = "0.5"
|
5
|
+
|
6
|
+
CONFIG_FILE = ".braids"
|
7
|
+
REQUIRED_GIT_VERSION = "1.6"
|
8
|
+
|
9
|
+
def self.verbose; @verbose || false; end
|
10
|
+
def self.verbose=(new_value); @verbose = !!new_value; end
|
11
|
+
|
12
|
+
def self.use_local_cache; [nil, "true", "1"].include?(ENV["BRAID_USE_LOCAL_CACHE"]); end
|
13
|
+
def self.local_cache_dir; File.expand_path(ENV["BRAID_LOCAL_CACHE_DIR"] || "#{ENV["HOME"]}/.braid/cache"); end
|
14
|
+
|
15
|
+
class BraidError < StandardError
|
16
|
+
def message
|
17
|
+
value = super
|
18
|
+
value if value != self.class.name
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'braid/operations'
|
24
|
+
require 'braid/mirror'
|
25
|
+
require 'braid/config'
|
26
|
+
require 'braid/command'
|
27
|
+
Dir[File.dirname(__FILE__) + '/braid/commands/*'].each do |file|
|
28
|
+
require file
|
29
|
+
end
|