braid 0.5

Sign up to get free protection for your applications and to get access to all the features.
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,230 @@
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
+ * does NOT remove the git and git svn remotes in case you still need them around
93
+ TXT
94
+
95
+ examples <<-TXT
96
+ . braid remove local/dir
97
+ TXT
98
+
99
+ mixin :argument_path, :option_verbose
100
+
101
+ run {
102
+ Braid.verbose = verbose
103
+ Braid::Command.run(:remove, path)
104
+ }
105
+ }
106
+
107
+ mode(:setup) {
108
+ description <<-TXT
109
+ Set up git or git-svn remote for a mirror.
110
+ All commands that need a remote run setup internally.
111
+
112
+ Defaults to setting up remotes for all mirrors if none is specified.
113
+ TXT
114
+
115
+ examples <<-TXT
116
+ . braid setup local/dir
117
+ TXT
118
+
119
+ mixin :optional_path, :option_verbose
120
+
121
+ run {
122
+ Braid.verbose = verbose
123
+ Braid::Command.run(:setup, path)
124
+ }
125
+ }
126
+
127
+ mode(:diff) {
128
+ description <<-TXT
129
+ Show diff of local changes to mirror.
130
+ TXT
131
+
132
+ examples <<-TXT
133
+ . braid diff local/dir
134
+ TXT
135
+
136
+ mixin :argument_path, :option_verbose
137
+
138
+ run {
139
+ Braid::Command.run(:diff, path)
140
+ }
141
+ }
142
+
143
+ mode(:version) {
144
+ description 'Show braid version.'
145
+
146
+ run {
147
+ puts "braid #{Braid::VERSION}"
148
+ }
149
+ }
150
+
151
+ mixin(:argument_path) {
152
+ argument(:path) {
153
+ attr
154
+ }
155
+ }
156
+
157
+ mixin(:optional_path) {
158
+ argument(:path) {
159
+ optional
160
+ attr
161
+ }
162
+ }
163
+
164
+ mixin(:argument_url) {
165
+ argument(:url) {
166
+ attr
167
+ }
168
+ }
169
+
170
+ mixin(:option_type) {
171
+ option(:type, :t) {
172
+ optional
173
+ argument :required
174
+ desc 'mirror type'
175
+ attr
176
+ }
177
+ }
178
+
179
+ mixin(:option_branch) {
180
+ option(:branch, :b) {
181
+ optional
182
+ argument :required
183
+ desc 'remote branch name'
184
+ attr
185
+ }
186
+ }
187
+
188
+ mixin(:option_rails_plugin) {
189
+ option(:rails_plugin, :p) {
190
+ optional
191
+ desc 'added mirror is a Rails plugin'
192
+ attr
193
+ }
194
+ }
195
+
196
+ mixin(:option_revision) {
197
+ option(:revision, :r) {
198
+ optional
199
+ argument :required
200
+ desc 'revision to track'
201
+ attr
202
+ }
203
+ }
204
+
205
+ mixin(:option_head) {
206
+ option(:head) {
207
+ optional
208
+ desc 'mirror head'
209
+ attr
210
+ }
211
+ }
212
+
213
+ mixin(:option_full) {
214
+ option(:full) {
215
+ optional
216
+ desc 'include mirror history' # FIXME
217
+ attr
218
+ }
219
+ }
220
+
221
+ mixin(:option_verbose) {
222
+ option(:verbose, :v) {
223
+ optional
224
+ desc 'log shell commands'
225
+ attr
226
+ }
227
+ }
228
+
229
+ run { help! }
230
+ }
data/braid.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{braid}
3
+ s.version = "0.5"
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/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