evilchelu-braid 0.4.13 → 0.5

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 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
@@ -106,7 +106,10 @@ Main {
106
106
 
107
107
  mode(:setup) {
108
108
  description <<-TXT
109
- Set up git and git-svn remotes.
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.
110
113
  TXT
111
114
 
112
115
  examples <<-TXT
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.4.13"
3
+ s.version = "0.5"
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-23}
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.extra_rdoc_files = ["README.rdoc"]
15
- 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.rdoc", "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"]
16
- s.has_rdoc = true
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
17
16
  s.homepage = %q{http://evil.che.lu/projects/braid}
18
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "braid", "--main", "README.rdoc"]
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
1
  $:.unshift File.dirname(__FILE__)
2
2
 
3
3
  module Braid
4
- VERSION = "0.4.13"
4
+ VERSION = "0.5"
5
5
 
6
6
  CONFIG_FILE = ".braids"
7
7
  REQUIRED_GIT_VERSION = "1.6"
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
@@ -30,15 +30,13 @@ module Braid
30
30
  config.update(mirror)
31
31
  add_config_file
32
32
 
33
- commit_message = "Add mirror '#{mirror.path}/'#{revision_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
@@ -3,6 +3,8 @@ module Braid
3
3
  class Diff < Command
4
4
  def run(path)
5
5
  mirror = config.get!(path)
6
+ setup_remote(mirror)
7
+
6
8
  diff = mirror.diff
7
9
  puts diff unless diff.empty?
8
10
  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 = "Remove mirror '#{mirror.path}/'"
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
@@ -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}/' already has a remote. Skipping."
20
+ msg "Setup: Mirror '#{mirror.path}' already has a remote. Reusing it." if verbose?
21
21
  return
22
22
  end
23
23
 
24
- msg "Setting up remote for '#{mirror.path}/'."
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}/' is locked to #{display_revision(mirror, mirror.lock)}. Skipping."
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}/' is already up to date. Skipping."
46
+ msg "Mirror '#{mirror.path}' is already up to date."
42
47
  return
43
48
  end
44
49
 
@@ -50,7 +55,7 @@ module Braid
50
55
  mirror.revision = new_revision
51
56
  mirror.lock = new_revision if options["revision"]
52
57
 
53
- msg "Updating mirror '#{mirror.path}/'."
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")
@@ -73,20 +78,21 @@ module Braid
73
78
  config.update(mirror)
74
79
  add_config_file
75
80
 
76
- commit_message = "Update mirror '#{mirror.path}/' to #{display_revision(mirror)}"
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
@@ -1,6 +1,7 @@
1
1
  require 'singleton'
2
2
  require 'rubygems'
3
3
  require 'open4'
4
+ require 'tempfile'
4
5
 
5
6
  module Braid
6
7
  module Operations
@@ -118,13 +119,13 @@ module Braid
118
119
  def sh(cmd, message = nil)
119
120
  message ||= "could not fetch" if cmd =~ /fetch/
120
121
  log(cmd)
121
- system(cmd)
122
- raise ShellExecutionError, message unless $? == 0
122
+ `#{cmd}`
123
+ raise ShellExecutionError, message unless $?.exitstatus == 0
123
124
  true
124
125
  end
125
126
 
126
127
  def msg(str)
127
- puts str
128
+ puts "Braid: #{str}"
128
129
  end
129
130
 
130
131
  def log(cmd)
@@ -138,7 +139,12 @@ module Braid
138
139
 
139
140
  class Git < Proxy
140
141
  def commit(message, *args)
141
- status, out, err = exec("git commit -m #{message.inspect} --no-verify #{args.join(' ')}")
142
+
143
+ commit_message_file = Tempfile.new("braid_commit", ".")
144
+ commit_message_file.print("Braid: " + message)
145
+ commit_message_file.flush
146
+ status, out, err = exec("git commit -F #{commit_message_file.path} --no-verify #{args.join(' ')}")
147
+ commit_message_file.unlink
142
148
 
143
149
  if status == 0
144
150
  true
@@ -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 =~ "Add mirror 'skit1/'"
27
+ output[0].should =~ /Braid: Added 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 =~ "Add mirror 'skit1/'"
62
+ output[0].should =~ /Braid: Added 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 =~ /Update mirror 'skit1\/' to '[0-9a-f]{7}'/
44
+ output[0].should =~ /Braid: Updated 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 =~ "Update mirror 'skit1/' to r3"
82
+ output[0].should =~ /Braid: Updated mirror 'skit1' to r3/
83
83
  end
84
84
 
85
85
  end
@@ -9,6 +9,7 @@ require 'pathname'
9
9
  TMP_PATH = File.join(Dir.tmpdir, "braid_integration")
10
10
  BRAID_PATH = Pathname.new(File.dirname(__FILE__)).parent.realpath
11
11
  FIXTURE_PATH = File.join(BRAID_PATH, "test", "fixtures")
12
+ FileUtils.rm_rf(TMP_PATH)
12
13
  FileUtils.mkdir_p(TMP_PATH)
13
14
  BRAID_BIN = File.join(BRAID_PATH, "bin", "braid")
14
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evilchelu-braid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.13
4
+ version: "0.5"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cristi Balan
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2008-10-23 00:00:00 -07:00
13
+ date: 2008-10-29 00:00:00 -07:00
14
14
  default_executable: braid
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -37,8 +37,8 @@ executables:
37
37
  - braid
38
38
  extensions: []
39
39
 
40
- extra_rdoc_files:
41
- - README.rdoc
40
+ extra_rdoc_files: []
41
+
42
42
  files:
43
43
  - bin/braid
44
44
  - braid.gemspec
@@ -54,7 +54,7 @@ files:
54
54
  - lib/braid.rb
55
55
  - LICENSE
56
56
  - Rakefile
57
- - README.rdoc
57
+ - README.textile
58
58
  - test/braid_test.rb
59
59
  - test/config_test.rb
60
60
  - test/fixtures/shiny/README
@@ -68,7 +68,7 @@ files:
68
68
  - test/mirror_test.rb
69
69
  - test/operations_test.rb
70
70
  - test/test_helper.rb
71
- has_rdoc: true
71
+ has_rdoc: false
72
72
  homepage: http://evil.che.lu/projects/braid
73
73
  post_install_message:
74
74
  rdoc_options:
@@ -77,7 +77,6 @@ rdoc_options:
77
77
  - --title
78
78
  - braid
79
79
  - --main
80
- - README.rdoc
81
80
  require_paths:
82
81
  - lib
83
82
  required_ruby_version: !ruby/object:Gem::Requirement
data/README.rdoc DELETED
@@ -1,27 +0,0 @@
1
- = braid
2
- A simple tool for tracking vendor branches in git.
3
-
4
- http://evil.che.lu/projects/braid/
5
-
6
- == Requirements
7
-
8
- You will need git 1.5.4.5 or higher to run this version.
9
-
10
- == Installation
11
-
12
- git clone git://github.com/evilchelu/braid.git
13
- cd braid
14
- gem build braid.gemspec
15
- sudo gem install braid-x.y.z.gem
16
-
17
- == Usage
18
-
19
- braid help
20
- braid help COMMANDNAME
21
-
22
- For more usage examples and documentation check the project wiki at http://github.com/evilchelu/braid/wikis.
23
- Also see the bug tracker at http://evilchelu.lighthouseapp.com/projects/10600-braid for current issues and future plans.
24
-
25
- == Contributing
26
-
27
- If you want to send a patch please fork the project on GitHub and send a pull request.