norbert-braid 0.4.13 → 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/README.textile +120 -0
- data/bin/braid +19 -18
- data/braid.gemspec +5 -6
- data/lib/braid.rb +4 -3
- data/lib/braid/command.rb +9 -1
- data/lib/braid/commands/add.rb +3 -5
- data/lib/braid/commands/diff.rb +2 -0
- data/lib/braid/commands/push.rb +47 -0
- data/lib/braid/commands/remove.rb +6 -2
- data/lib/braid/commands/setup.rb +2 -2
- data/lib/braid/commands/update.rb +15 -9
- data/lib/braid/mirror.rb +1 -1
- data/lib/braid/operations.rb +17 -7
- data/lib/core_ext.rb +13 -0
- metadata +11 -18
- data/README.rdoc +0 -27
- data/test/fixtures/shiny/README +0 -3
- data/test/fixtures/skit1.1/layouts/layout.liquid +0 -219
- data/test/fixtures/skit1.2/layouts/layout.liquid +0 -221
- data/test/fixtures/skit1/layouts/layout.liquid +0 -219
- data/test/fixtures/skit1/preview.png +0 -0
- data/test/integration/adding_test.rb +0 -80
- data/test/integration/updating_test.rb +0 -87
- data/test/integration_helper.rb +0 -69
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/bin/braid
CHANGED
@@ -92,10 +92,6 @@ Main {
|
|
92
92
|
* does NOT remove the git and git svn remotes in case you still need them around
|
93
93
|
TXT
|
94
94
|
|
95
|
-
examples <<-TXT
|
96
|
-
. braid remove local/dir
|
97
|
-
TXT
|
98
|
-
|
99
95
|
mixin :argument_path, :option_verbose
|
100
96
|
|
101
97
|
run {
|
@@ -104,36 +100,41 @@ Main {
|
|
104
100
|
}
|
105
101
|
}
|
106
102
|
|
107
|
-
mode(:
|
103
|
+
mode(:diff) {
|
108
104
|
description <<-TXT
|
109
|
-
|
105
|
+
Show diff of local changes to mirror.
|
110
106
|
TXT
|
111
107
|
|
112
|
-
|
113
|
-
|
108
|
+
mixin :argument_path, :option_verbose
|
109
|
+
|
110
|
+
run {
|
111
|
+
Braid::Command.run(:diff, path)
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
mode(:push) {
|
116
|
+
description <<-TXT
|
117
|
+
Push local mirror changes to remote.
|
114
118
|
TXT
|
115
119
|
|
116
|
-
mixin :
|
120
|
+
mixin :argument_path, :option_verbose
|
117
121
|
|
118
122
|
run {
|
119
123
|
Braid.verbose = verbose
|
120
|
-
Braid::Command.run(:
|
124
|
+
Braid::Command.run(:push, path)
|
121
125
|
}
|
122
126
|
}
|
123
127
|
|
124
|
-
mode(:
|
128
|
+
mode(:setup) {
|
125
129
|
description <<-TXT
|
126
|
-
|
127
|
-
TXT
|
128
|
-
|
129
|
-
examples <<-TXT
|
130
|
-
. braid diff local/dir
|
130
|
+
Set up git and git-svn remotes.
|
131
131
|
TXT
|
132
132
|
|
133
|
-
mixin :
|
133
|
+
mixin :optional_path, :option_verbose
|
134
134
|
|
135
135
|
run {
|
136
|
-
Braid
|
136
|
+
Braid.verbose = verbose
|
137
|
+
Braid::Command.run(:setup, path)
|
137
138
|
}
|
138
139
|
}
|
139
140
|
|
data/braid.gemspec
CHANGED
@@ -1,21 +1,20 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{braid}
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.5.1"
|
4
4
|
|
5
5
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Cristi Balan", "Norbert Crombach"]
|
9
|
-
s.date = %q{2008-10-
|
9
|
+
s.date = %q{2008-10-29}
|
10
10
|
s.default_executable = %q{braid}
|
11
11
|
s.description = %q{A simple tool for tracking vendor branches in git.}
|
12
12
|
s.email = %q{evil@che.lu}
|
13
13
|
s.executables = ["braid"]
|
14
|
-
s.
|
15
|
-
s.
|
16
|
-
s.has_rdoc = true
|
14
|
+
s.files = ["LICENSE", "Rakefile", "README.textile", "braid.gemspec", "bin/braid", "lib/braid/command.rb", "lib/braid/commands/add.rb", "lib/braid/commands/diff.rb", "lib/braid/commands/push.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", "lib/core_ext.rb", "test/braid_test.rb", "test/config_test.rb", "test/mirror_test.rb", "test/operations_test.rb", "test/test_helper.rb"]
|
15
|
+
s.has_rdoc = false
|
17
16
|
s.homepage = %q{http://evil.che.lu/projects/braid}
|
18
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "braid", "--main"
|
17
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "braid", "--main"]
|
19
18
|
s.require_paths = ["lib"]
|
20
19
|
s.rubyforge_project = %q{braid}
|
21
20
|
s.rubygems_version = %q{1.1.0}
|
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.5.1"
|
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
|
data/lib/braid/command.rb
CHANGED
@@ -23,7 +23,7 @@ module Braid
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.msg(str)
|
26
|
-
puts str
|
26
|
+
puts "Braid: #{str}"
|
27
27
|
end
|
28
28
|
|
29
29
|
def msg(str)
|
@@ -34,7 +34,15 @@ module Braid
|
|
34
34
|
@config ||= load_and_migrate_config
|
35
35
|
end
|
36
36
|
|
37
|
+
def verbose?
|
38
|
+
Braid.verbose
|
39
|
+
end
|
40
|
+
|
37
41
|
private
|
42
|
+
def setup_remote(mirror)
|
43
|
+
Command.run(:setup, mirror.path)
|
44
|
+
end
|
45
|
+
|
38
46
|
def use_local_cache?
|
39
47
|
Braid.use_local_cache
|
40
48
|
end
|
data/lib/braid/commands/add.rb
CHANGED
@@ -30,15 +30,13 @@ module Braid
|
|
30
30
|
config.update(mirror)
|
31
31
|
add_config_file
|
32
32
|
|
33
|
-
commit_message = "
|
33
|
+
commit_message = "Added mirror '#{mirror.path}' at #{display_revision(mirror)}"
|
34
|
+
|
34
35
|
git.commit(commit_message)
|
36
|
+
msg commit_message
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
|
-
private
|
39
|
-
def setup_remote(mirror)
|
40
|
-
Command.run(:setup, mirror.path)
|
41
|
-
end
|
42
40
|
end
|
43
41
|
end
|
44
42
|
end
|
data/lib/braid/commands/diff.rb
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'tmpdir'
|
3
|
+
|
4
|
+
module Braid
|
5
|
+
module Commands
|
6
|
+
class Push < Command
|
7
|
+
def run(path, options = {})
|
8
|
+
mirror = config.get!(path)
|
9
|
+
|
10
|
+
#mirror.fetch
|
11
|
+
|
12
|
+
base_revision = git.rev_parse(mirror.remote)
|
13
|
+
unless mirror.merged?(base_revision)
|
14
|
+
msg "Mirror is not up to date. Stopping."
|
15
|
+
return
|
16
|
+
end
|
17
|
+
|
18
|
+
diff = mirror.diff
|
19
|
+
if diff.empty?
|
20
|
+
msg "No local changes found. Stopping."
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
clone_dir = Dir.tmpdir + "/braid_push.#{$$}"
|
25
|
+
Dir.mkdir(clone_dir)
|
26
|
+
source_dir = Dir.pwd
|
27
|
+
remote_url = git.remote_url(mirror.remote)
|
28
|
+
if File.directory?(remote_url)
|
29
|
+
remote_url = File.expand_path(remote_url)
|
30
|
+
end
|
31
|
+
STDOUT.puts remote_url
|
32
|
+
Dir.chdir(clone_dir) do
|
33
|
+
msg "Cloning mirror with local changes."
|
34
|
+
git.init
|
35
|
+
git.fetch(source_dir)
|
36
|
+
git.fetch(remote_url)
|
37
|
+
git.checkout(base_revision)
|
38
|
+
git.apply(diff)
|
39
|
+
system("git commit -v")
|
40
|
+
msg "Pushing changes to remote."
|
41
|
+
git.push(remote_url, "HEAD:#{mirror.branch}")
|
42
|
+
end
|
43
|
+
FileUtils.rm_r(clone_dir)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -7,15 +7,19 @@ module Braid
|
|
7
7
|
bail_on_local_changes!
|
8
8
|
|
9
9
|
with_reset_on_error do
|
10
|
-
msg "Removing mirror from '#{mirror.path}
|
10
|
+
msg "Removing mirror from '#{mirror.path}'."
|
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
|
+
|
14
17
|
config.remove(mirror)
|
15
18
|
add_config_file
|
16
19
|
|
17
|
-
commit_message = "
|
20
|
+
commit_message = "Removed mirror '#{mirror.path}'"
|
18
21
|
git.commit(commit_message)
|
22
|
+
msg commit_message
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
data/lib/braid/commands/setup.rb
CHANGED
@@ -17,11 +17,11 @@ module Braid
|
|
17
17
|
mirror = config.get!(path)
|
18
18
|
|
19
19
|
if git.remote_url(mirror.remote)
|
20
|
-
msg "Mirror '#{mirror.path}
|
20
|
+
msg "Setup: Mirror '#{mirror.path}' already has a remote. Reusing it." if verbose?
|
21
21
|
return
|
22
22
|
end
|
23
23
|
|
24
|
-
msg "
|
24
|
+
msg "Setup: Creating remote for '#{mirror.path}'."
|
25
25
|
unless mirror.type == "svn"
|
26
26
|
url = use_local_cache? ? git_cache.path(mirror.url) : mirror.url
|
27
27
|
git.remote_add(mirror.remote, url, mirror.branch)
|
@@ -21,24 +21,29 @@ module Braid
|
|
21
21
|
def update_one(path, options = {})
|
22
22
|
mirror = config.get!(path)
|
23
23
|
|
24
|
+
revision_message = options["revision"] ? " to #{display_revision(mirror, options["revision"])}" : ""
|
25
|
+
msg "Updating mirror '#{mirror.path}'#{revision_message}."
|
26
|
+
|
24
27
|
# check options for lock modification
|
25
28
|
if mirror.locked?
|
26
29
|
if options["head"]
|
27
|
-
msg "Unlocking mirror '#{mirror.path}
|
30
|
+
msg "Unlocking mirror '#{mirror.path}'." if verbose?
|
28
31
|
mirror.lock = nil
|
29
32
|
elsif !options["revision"]
|
30
|
-
msg "Mirror '#{mirror.path}
|
33
|
+
msg "Mirror '#{mirror.path}' is locked to #{display_revision(mirror, mirror.lock)}. Use --head to force."
|
31
34
|
return
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
38
|
+
setup_remote(mirror)
|
39
|
+
msg "Fetching new commits for '#{mirror.path}'." if verbose?
|
35
40
|
mirror.fetch
|
36
41
|
|
37
42
|
new_revision = validate_new_revision(mirror, options["revision"])
|
38
43
|
target_revision = determine_target_revision(mirror, new_revision)
|
39
44
|
|
40
45
|
if mirror.merged?(target_revision)
|
41
|
-
msg "Mirror '#{mirror.path}
|
46
|
+
msg "Mirror '#{mirror.path}' is already up to date."
|
42
47
|
return
|
43
48
|
end
|
44
49
|
|
@@ -50,11 +55,11 @@ module Braid
|
|
50
55
|
mirror.revision = new_revision
|
51
56
|
mirror.lock = new_revision if options["revision"]
|
52
57
|
|
53
|
-
msg "
|
58
|
+
msg "Merging in mirror '#{mirror.path}'." if verbose?
|
54
59
|
begin
|
55
60
|
if mirror.squashed?
|
56
61
|
local_hash = git.rev_parse("HEAD")
|
57
|
-
if diff
|
62
|
+
if !diff.empty?
|
58
63
|
base_hash = generate_tree_hash(mirror, base_revision)
|
59
64
|
else
|
60
65
|
base_hash = local_hash
|
@@ -73,20 +78,21 @@ module Braid
|
|
73
78
|
config.update(mirror)
|
74
79
|
add_config_file
|
75
80
|
|
76
|
-
commit_message = "
|
81
|
+
commit_message = "Updated mirror '#{mirror.path}' to #{display_revision(mirror)}"
|
77
82
|
|
78
83
|
if error
|
79
84
|
File.open(".git/MERGE_MSG", 'w') { |f| f.puts(commit_message) }
|
80
85
|
return
|
81
|
-
else
|
82
|
-
git.commit(commit_message)
|
83
86
|
end
|
87
|
+
|
88
|
+
git.commit(commit_message)
|
89
|
+
msg commit_message
|
84
90
|
end
|
85
91
|
|
86
92
|
def generate_tree_hash(mirror, revision)
|
87
93
|
git.rm_r(mirror.path)
|
88
94
|
git.read_tree_prefix(revision, mirror.path)
|
89
|
-
success = git.commit("Temporary commit for mirror '#{mirror.path}
|
95
|
+
success = git.commit("Temporary commit for mirror '#{mirror.path}'")
|
90
96
|
hash = git.rev_parse("HEAD")
|
91
97
|
git.reset_hard("HEAD^") if success
|
92
98
|
hash
|