braid 1.0.15 → 1.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afbdb15969e052393b88693a8b6079066d180052
4
- data.tar.gz: a5198d79c0cff3d4ba868d3e644d4233d2838e99
3
+ metadata.gz: 78d66492c589068152aee142e694bf02ee1201bd
4
+ data.tar.gz: 54d080bf631011a6c09e8882337539eaed2b510f
5
5
  SHA512:
6
- metadata.gz: 75ffd2beb47c5cb36320e1a326ffb48d6bc6d2e8aaaf83e809b5e22cbbf763cbe63e31261f577fff8d6cad4102247fb98315362d095dbcc3e5da2471e09910a0
7
- data.tar.gz: 0c53d7fda15233809526ef8b45318ce9175a8d2ea4030d786e46a9601fc397a822674842a9a9975e67a22716846c8a6a97e77d025de362a4974d6292d1197225
6
+ metadata.gz: dbde11ac65aae3c78581e0d99e90def3b997d72929723abcb9fb097d7743cd8ebb8697a8ae161a5af1795fdc632745f86928bddae45b08cc847d6ded37dbdebb
7
+ data.tar.gz: 1e52e6ad9304532cf6c8e340b9b57643e5550e9f4858ac1d798abcc116d1cc1e45355ada3b92cd76ac3d60ffcb9b4ad0c03650ea3b3550032b26fb1d24c83a6d
data/README.md CHANGED
@@ -76,6 +76,12 @@ to the grit project:
76
76
 
77
77
  braid diff lib/grit > grit.patch
78
78
 
79
+ Alternatively you can push changes back to the source directory directly using the following command. The command
80
+ will push the changes to the branch `myproject_customizations` that has been branched off the source branch (`master`
81
+ in this example). Omit the `--branch` argument to push directly to the source branch.
82
+
83
+ braid push lib/grit --branch myproject_customizations
84
+
79
85
  Once those changes have been applied to grit you probably want to update your local version of grit again.
80
86
 
81
87
  braid update lib/grit
data/bin/braid CHANGED
@@ -40,11 +40,11 @@ Main {
40
40
  . braid add http://remote/path local/dir
41
41
  TXT
42
42
 
43
- mixin :argument_url, :optional_path, :option_branch, :option_revision, :option_full, :option_verbose
43
+ mixin :argument_url, :optional_path, :option_branch, :option_revision, :option_full, :option_verbose, :option_remote_path
44
44
 
45
45
  run {
46
46
  Braid.verbose = verbose
47
- Braid::Command.run(:add, url, {'path' => path, 'branch' => branch, 'revision' => revision, 'full' => full})
47
+ Braid::Command.run(:add, url, {'path' => path, 'branch' => branch, 'revision' => revision, 'full' => full, 'remote_path' => remote_path})
48
48
  }
49
49
  }
50
50
 
@@ -113,6 +113,7 @@ Main {
113
113
  options = {
114
114
  'keep' => keep
115
115
  }
116
+ Braid.verbose = verbose
116
117
  Braid::Command.run(:diff, path, options)
117
118
  }
118
119
  }
@@ -206,6 +207,15 @@ Main {
206
207
  }
207
208
  }
208
209
 
210
+ mixin(:option_remote_path) {
211
+ option(:remote_path, :p) {
212
+ optional
213
+ argument :required
214
+ desc 'remote path'
215
+ attr
216
+ }
217
+ }
218
+
209
219
  mixin(:option_revision) {
210
220
  option(:revision, :r) {
211
221
  optional
data/lib/braid/command.rb CHANGED
@@ -89,7 +89,7 @@ module Braid
89
89
  end
90
90
 
91
91
  def validate_new_revision(mirror, new_revision)
92
- return git.rev_parse(mirror.remote) unless new_revision
92
+ return git.rev_parse("#{mirror.remote}/#{mirror.branch}") unless new_revision
93
93
 
94
94
  new_revision = git.rev_parse(new_revision)
95
95
  old_revision = mirror.revision
@@ -101,8 +101,8 @@ module Braid
101
101
  new_revision
102
102
  end
103
103
 
104
- def determine_target_revision(new_revision)
105
- git.rev_parse(new_revision)
104
+ def determine_target_revision(mirror, new_revision)
105
+ git.rev_parse(mirror.versioned_path(new_revision))
106
106
  end
107
107
  end
108
108
  end
@@ -4,6 +4,7 @@ module Braid
4
4
  def run(url, options = {})
5
5
  with_reset_on_error do
6
6
  mirror = config.add_from_options(url, options)
7
+ add_config_file
7
8
 
8
9
  branch_message = (mirror.branch == 'master') ? '' : " branch '#{mirror.branch}'"
9
10
  revision_message = options['revision'] ? " at #{display_revision(mirror, options['revision'])}" : ''
@@ -16,7 +17,7 @@ module Braid
16
17
  mirror.fetch
17
18
 
18
19
  new_revision = validate_new_revision(mirror, options['revision'])
19
- target_revision = determine_target_revision(new_revision)
20
+ target_revision = determine_target_revision(mirror, new_revision)
20
21
 
21
22
  unless mirror.squashed?
22
23
  git.merge_ours(target_revision)
@@ -2,14 +2,12 @@ module Braid
2
2
  module Commands
3
3
  class Diff < Command
4
4
  def run(path = nil, options = {})
5
- with_reset_on_error do
6
- path ? diff_one(path, options) : diff_all(options)
7
- end
5
+ path ? diff_one(path, options) : diff_all(options)
8
6
  end
9
7
 
10
8
  protected
11
9
 
12
- def diff_all(options = {})
10
+ def diff_all(options = {})
13
11
  print "\n"
14
12
  msg "Diffing all mirrors.\n=======================================================\n"
15
13
  config.mirrors.each do |path|
@@ -12,7 +12,7 @@ module Braid
12
12
  setup_remote(mirror)
13
13
  mirror.fetch
14
14
 
15
- base_revision = git.rev_parse(mirror.remote)
15
+ base_revision = git.rev_parse("#{mirror.remote}/#{mirror.branch}")
16
16
  unless mirror.merged?(base_revision)
17
17
  msg 'Mirror is not up to date. Stopping.'
18
18
  clear_remote(mirror, options)
@@ -40,7 +40,9 @@ module Braid
40
40
  git.fetch(mirror.cached_url) if File.exist?(mirror.cached_url)
41
41
  git.fetch(remote_url, "+refs/heads/#{mirror.branch}")
42
42
  git.checkout(base_revision)
43
- git.apply(diff)
43
+ args =[]
44
+ args << "--directory=#{mirror.remote_path}" if mirror.remote_path
45
+ git.apply(diff, args)
44
46
  system('git commit -v')
45
47
  msg "Pushing changes to remote branch #{branch}."
46
48
  git.push(remote_url, "HEAD:refs/heads/#{branch}")
@@ -29,7 +29,7 @@ module Braid
29
29
 
30
30
  msg "Setup: Creating remote for '#{mirror.path}'." if verbose?
31
31
  url = use_local_cache? ? git_cache.path(mirror.url) : mirror.url
32
- git.remote_add(mirror.remote, url, mirror.branch)
32
+ git.remote_add(mirror.remote, url)
33
33
  end
34
34
  end
35
35
  end
@@ -13,7 +13,7 @@ module Braid
13
13
  print "\n"
14
14
  msg "Listing all mirrors.\n=======================================================\n"
15
15
  config.mirrors.each do |path|
16
- list_one(path, options)
16
+ status_one(path, options)
17
17
  end
18
18
  print "\n"
19
19
  end
@@ -45,19 +45,17 @@ module Braid
45
45
  rescue InvalidRevision
46
46
  # Ignored as it means the revision matches expected
47
47
  end
48
- target_revision = determine_target_revision(new_revision)
48
+ target_revision = determine_target_revision(mirror, new_revision)
49
+ current_revision = determine_target_revision(mirror, mirror.base_revision)
49
50
 
50
- if (options['revision'] && was_locked && target_revision == mirror.base_revision) ||
51
- (options['revision'].nil? && !was_locked && mirror.merged?(target_revision))
51
+ if (options['revision'] && was_locked && target_revision == current_revision) ||
52
+ (options['revision'].nil? && !was_locked && mirror.merged?(git.rev_parse(new_revision)))
52
53
  msg "Mirror '#{mirror.path}' is already up to date."
53
54
  clear_remote(mirror, options)
54
55
  return
55
56
  end
56
57
 
57
- if mirror.squashed?
58
- diff = mirror.diff
59
- base_revision = mirror.base_revision
60
- end
58
+ base_revision = mirror.base_revision if mirror.squashed?
61
59
 
62
60
  mirror.revision = new_revision
63
61
  mirror.lock = new_revision if options['revision']
@@ -67,7 +65,7 @@ module Braid
67
65
  begin
68
66
  if mirror.squashed?
69
67
  local_hash = git.rev_parse('HEAD')
70
- base_hash = generate_tree_hash(mirror, base_revision)
68
+ base_hash = generate_tree_hash(mirror, mirror.versioned_path(base_revision))
71
69
  remote_hash = generate_tree_hash(mirror, target_revision)
72
70
  ENV["GITHEAD_#{local_hash}"] = 'HEAD'
73
71
  ENV["GITHEAD_#{remote_hash}"] = target_revision
data/lib/braid/mirror.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Braid
2
2
  class Mirror
3
- ATTRIBUTES = %w(url branch squashed revision lock)
3
+ ATTRIBUTES = %w(url branch squashed revision lock remote_path)
4
4
 
5
5
  class UnknownType < BraidError
6
6
  def message
@@ -32,7 +32,9 @@ module Braid
32
32
 
33
33
  squashed = !options['full']
34
34
 
35
- attributes = {'url' => url, 'branch' => branch, 'squashed' => squashed}
35
+ remote_path = options['remote_path']
36
+
37
+ attributes = {'url' => url, 'branch' => branch, 'squashed' => squashed, 'remote_path' => remote_path}
36
38
  self.new(path, attributes)
37
39
  end
38
40
 
@@ -59,9 +61,13 @@ module Braid
59
61
  end
60
62
  end
61
63
 
64
+ def versioned_path(revision)
65
+ "#{revision}:#{self.remote_path}"
66
+ end
67
+
62
68
  def diff
63
69
  fetch
64
- remote_hash = git.rev_parse("#{base_revision}:")
70
+ remote_hash = git.rev_parse(versioned_path(base_revision))
65
71
  local_hash = git.tree_hash(path)
66
72
  remote_hash != local_hash ? git.diff_tree(remote_hash, local_hash) : ''
67
73
  end
@@ -95,10 +101,10 @@ module Braid
95
101
 
96
102
  def method_missing(name, *args)
97
103
  if ATTRIBUTES.find { |attribute| name.to_s =~ /^(#{attribute})(=)?$/ }
98
- unless $2
99
- attributes[$1]
100
- else
104
+ if $2
101
105
  attributes[$1] = args[0]
106
+ else
107
+ attributes[$1]
102
108
  end
103
109
  else
104
110
  raise NameError, "unknown attribute `#{name}'"
@@ -113,7 +119,8 @@ module Braid
113
119
  hash = nil
114
120
  local_commits.each do |local_commit|
115
121
  local_tree = git.tree_hash(path, local_commit)
116
- if match = remote_hashes.find { |_, remote_tree| local_tree == remote_tree }
122
+ match = remote_hashes.find { |_, remote_tree| local_tree == remote_tree }
123
+ if match
117
124
  hash = match[0]
118
125
  break
119
126
  end
@@ -219,8 +219,8 @@ module Braid
219
219
  end
220
220
 
221
221
  # Implies tracking.
222
- def remote_add(remote, path, branch)
223
- invoke(:remote, 'add', "-t #{branch} -m #{branch}", remote, path)
222
+ def remote_add(remote, path)
223
+ invoke(:remote, 'add', remote, path)
224
224
  true
225
225
  end
226
226
 
data/lib/braid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Braid
2
- VERSION = '1.0.15'
2
+ VERSION = '1.0.16'
3
3
  end
@@ -31,7 +31,7 @@ describe 'Adding a mirror in a clean repository' do
31
31
  run_command("#{BRAID_BIN} add #{@skit1}")
32
32
  end
33
33
 
34
- braids = YAML::load_file("#{@shiny}/#{Braid::CONFIG_FILE}")
34
+ braids = YAML::load_file("#{@shiny}/.braids.json")
35
35
  braids['skit1']['squashed'].should == true
36
36
  braids['skit1']['url'].should == @skit1
37
37
  braids['skit1']['revision'].should_not be_nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: braid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.15
4
+ version: 1.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cristi Balan
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-03-19 00:00:00.000000000 Z
13
+ date: 2017-03-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: main