braid 1.0.13 → 1.0.14

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7da0717c5630a66b413b1017a48faab2c8985eb
4
- data.tar.gz: 370241cf4019745d32295bc81540a938b92a7c6c
3
+ metadata.gz: 2ea7f832727df1483b0ba45181553cf061f2539a
4
+ data.tar.gz: dab214bf42041f02f3b6edd29cc8229866689199
5
5
  SHA512:
6
- metadata.gz: ee8069fa55924180bbb01ba8c8ccd6896260b5676cd193a4049c895bb9a89005057f99ef7857968a3a791dedd7546137a155a4a4047d0916016ed2df23284416
7
- data.tar.gz: 5cd58bac89bc692b33e9c9cc6ff39c11847b29f15a33dbb41f734010fd9a186189d86ac8f1bb8dfd7dcf10fb8bcd9c2498dfe3d91bb5da787f2e8de5a28fd775
6
+ metadata.gz: 5aba65dd373480d84c90ea6d4ff7c1e664fcf360d1c344339dccf1a5f92c20f8c2c392793dce5f58cbad7c081d35044a55e64b6871067dbb861080dc796b4d8f
7
+ data.tar.gz: 190985839fe84ff0157dda1debcd3021c547e1a5d8164f011fab647ba644323957e62158f462dcd6a115da1f40797c418f054da5e9791a016d9f69f5c9dafdd0
@@ -1,10 +1,20 @@
1
1
  language: ruby
2
+ sudo: false
2
3
  rvm:
3
- - 2.1.3
4
+ - 2.3.1
4
5
  - 1.9.3
5
6
  - jruby-19mode
6
7
  - jruby-18mode
8
+ addons:
9
+ apt:
10
+ sources:
11
+ - git-core
12
+ packages:
13
+ - git
7
14
  git:
8
15
  depth: 10
9
16
  before_install:
17
+ - git --version
18
+ - git config --global user.name "Somebody"
19
+ - git config --global user.email "you@example.com"
10
20
  - gem update bundler
data/bin/braid CHANGED
@@ -122,11 +122,12 @@ Main {
122
122
  Push local mirror changes to remote.
123
123
  TXT
124
124
 
125
- mixin :argument_path, :option_verbose, :option_keep_remote
125
+ mixin :argument_path, :option_branch, :option_verbose, :option_keep_remote
126
126
 
127
127
  run {
128
128
  options = {
129
- 'keep' => keep
129
+ 'keep' => keep,
130
+ 'branch' => branch
130
131
  }
131
132
  Braid.verbose = verbose
132
133
  Braid::Command.run(:push, path, options)
@@ -7,6 +7,8 @@ module Braid
7
7
  def run(path, options = {})
8
8
  mirror = config.get!(path)
9
9
 
10
+ branch = options['branch'] || mirror.branch
11
+
10
12
  setup_remote(mirror)
11
13
  mirror.fetch
12
14
 
@@ -40,8 +42,8 @@ module Braid
40
42
  git.checkout(base_revision)
41
43
  git.apply(diff)
42
44
  system('git commit -v')
43
- msg 'Pushing changes to remote.'
44
- git.push(remote_url, "HEAD:#{mirror.branch}")
45
+ msg "Pushing changes to remote branch #{branch}."
46
+ git.push(remote_url, "HEAD:refs/heads/#{branch}")
45
47
  end
46
48
  FileUtils.rm_r(clone_dir)
47
49
 
@@ -41,7 +41,7 @@ module Braid
41
41
 
42
42
  new_revision = options['revision']
43
43
  begin
44
- new_revision = validate_new_revision(mirror, options['revision'])
44
+ new_revision = validate_new_revision(mirror, new_revision)
45
45
  rescue InvalidRevision
46
46
  # Ignored as it means the revision matches expected
47
47
  end
@@ -152,7 +152,7 @@ module Braid
152
152
  end
153
153
 
154
154
  def log(cmd)
155
- msg "Executing `#{cmd}`" if verbose?
155
+ msg "Executing `#{cmd}` in #{Dir.pwd}" if verbose?
156
156
  end
157
157
 
158
158
  def verbose?
@@ -1,3 +1,3 @@
1
1
  module Braid
2
- VERSION = '1.0.13'
2
+ VERSION = '1.0.14'
3
3
  end
@@ -0,0 +1,88 @@
1
+ require File.dirname(__FILE__) + '/../integration_helper'
2
+
3
+ describe 'Pushing to a mirror' do
4
+
5
+ before do
6
+ FileUtils.rm_rf(TMP_PATH)
7
+ FileUtils.mkdir_p(TMP_PATH)
8
+ end
9
+
10
+ describe 'from a git repository' do
11
+ before do
12
+ @repository_dir = create_git_repo_from_fixture('shiny')
13
+ @vendor_repository_dir = create_git_repo_from_fixture('skit1')
14
+ @file_name = 'layouts/layout.liquid'
15
+
16
+ in_dir(@repository_dir) do
17
+ run_command("#{BRAID_BIN} add #{@vendor_repository_dir}")
18
+ end
19
+
20
+ in_dir(@vendor_repository_dir) do
21
+ run_command('git config receive.denyCurrentBranch updateInstead')
22
+ end
23
+
24
+ update_dir_from_fixture('shiny/skit1', 'skit1.1')
25
+ in_dir(@repository_dir) do
26
+ run_command('git add *')
27
+ run_command('git commit -m "Make some changes to vendored files"')
28
+ end
29
+ end
30
+
31
+ context 'with remote updtodate' do
32
+ it 'should push changes successfully' do
33
+ braid_output = nil
34
+ in_dir(@repository_dir) do
35
+ set_editor_message('Make some changes')
36
+ braid_output = run_command("#{EDITOR_CMD_PREFIX} #{BRAID_BIN} push skit1")
37
+ end
38
+ braid_output.should =~ /Braid: Cloning mirror with local changes./
39
+ braid_output.should =~ /Make some changes/
40
+ braid_output.should =~ /Braid: Pushing changes to remote branch master./
41
+
42
+ assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
43
+ assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
44
+ end
45
+
46
+ it 'should push changes to specified branch successfully' do
47
+ braid_output = nil
48
+ in_dir(@repository_dir) do
49
+ set_editor_message('Make some changes')
50
+ braid_output = run_command("#{EDITOR_CMD_PREFIX} #{BRAID_BIN} push skit1 --branch MyBranch")
51
+ end
52
+ braid_output.should =~ /Braid: Cloning mirror with local changes./
53
+ braid_output.should =~ /Make some changes/
54
+ braid_output.should =~ /Braid: Pushing changes to remote branch MyBranch./
55
+
56
+ assert_no_diff("#{FIXTURE_PATH}/skit1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
57
+ assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@repository_dir}/skit1/#{@file_name}")
58
+
59
+ in_dir(@vendor_repository_dir) do
60
+ run_command('git checkout MyBranch 2>&1')
61
+ end
62
+
63
+ assert_no_diff("#{FIXTURE_PATH}/skit1.1/#{@file_name}", "#{@vendor_repository_dir}/#{@file_name}")
64
+ end
65
+ end
66
+
67
+ context 'with remote having changes' do
68
+ before do
69
+ update_dir_from_fixture('skit1', 'skit1.1')
70
+ update_dir_from_fixture('skit1', 'skit1.2')
71
+ in_dir(@vendor_repository_dir) do
72
+ run_command('git add *')
73
+ run_command('git commit -m "Update vendored directory"')
74
+ end
75
+ end
76
+ it 'should push changes successfully' do
77
+ braid_output = nil
78
+ in_dir(@repository_dir) do
79
+ set_editor_message('Make some changes')
80
+ braid_output = run_command("#{EDITOR_CMD_PREFIX} #{BRAID_BIN} push skit1")
81
+ end
82
+ braid_output.should =~ /Braid: Mirror is not up to date. Stopping./
83
+
84
+ assert_no_diff("#{FIXTURE_PATH}/skit1.2/#{@file_name}", "#{TMP_PATH}/skit1/#{@file_name}")
85
+ end
86
+ end
87
+ end
88
+ end
@@ -97,9 +97,9 @@ describe 'Updating a mirror' do
97
97
  run_command('git commit -m "delete here too"')
98
98
  end
99
99
 
100
- # Without the fix, when git diffs the base and local trees, it will
101
- # think skit1/layouts/layout.liquid was renamed to
102
- # other-skit/layout.liquid, resulting in a rename-delete conflict.
100
+ # Without the fix, when git diffs the base and local trees, it will
101
+ # think skit1/layouts/layout.liquid was renamed to
102
+ # other-skit/layout.liquid, resulting in a rename-delete conflict.
103
103
  braid_output = nil
104
104
  in_dir(@shiny) do
105
105
  braid_output = run_command("#{BRAID_BIN} update skit1")
@@ -7,6 +7,8 @@ require 'fileutils'
7
7
  require 'pathname'
8
8
 
9
9
  TMP_PATH = File.join(Dir.tmpdir, 'braid_integration')
10
+ EDITOR_CMD = "#{TMP_PATH}/editor"
11
+ EDITOR_CMD_PREFIX = "GIT_EDITOR=#{EDITOR_CMD}"
10
12
  BRAID_PATH = Pathname.new(File.dirname(__FILE__)).parent.realpath
11
13
  FIXTURE_PATH = File.join(BRAID_PATH, 'spec', 'fixtures')
12
14
  FileUtils.rm_rf(TMP_PATH)
@@ -14,6 +16,18 @@ FileUtils.mkdir_p(TMP_PATH)
14
16
 
15
17
  BRAID_BIN = ((defined?(JRUBY_VERSION) || Gem.win_platform?) ? 'ruby ' : '') + File.join(BRAID_PATH, 'bin', 'braid')
16
18
 
19
+ def set_editor_message(message = 'Make some changes')
20
+ File.write(EDITOR_CMD, <<CMD)
21
+ #!/usr/bin/env ruby
22
+ File.write(ARGV[0], #{message.inspect})
23
+ CMD
24
+ FileUtils.chmod 0755, EDITOR_CMD
25
+ end
26
+
27
+ def assert_no_diff(file1, file2)
28
+ run_command("diff -U 3 #{file1} #{file2}")
29
+ end
30
+
17
31
  def in_dir(dir = TMP_PATH)
18
32
  Dir.chdir(dir)
19
33
  yield
@@ -31,8 +45,8 @@ def update_dir_from_fixture(dir, fixture = dir)
31
45
  FileUtils.cp_r(File.join(FIXTURE_PATH, fixture) + '/.', to_dir)
32
46
  end
33
47
 
34
- def create_git_repo_from_fixture(fixture_name)
35
- git_repo = File.join(TMP_PATH, fixture_name)
48
+ def create_git_repo_from_fixture(fixture_name, directory = fixture_name)
49
+ git_repo = File.join(TMP_PATH, directory)
36
50
  update_dir_from_fixture(fixture_name)
37
51
 
38
52
  in_dir(git_repo) do
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.13
4
+ version: 1.0.14
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-11 00:00:00.000000000 Z
13
+ date: 2017-03-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: main
@@ -113,6 +113,7 @@ files:
113
113
  - spec/fixtures/skit1/layouts/layout.liquid
114
114
  - spec/fixtures/skit1/preview.png
115
115
  - spec/integration/adding_spec.rb
116
+ - spec/integration/push_spec.rb
116
117
  - spec/integration/updating_spec.rb
117
118
  - spec/integration_helper.rb
118
119
  - spec/mirror_spec.rb