vx-common 0.2.0.pre31 → 0.2.0.pre32

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: c5d36777c4485eeccb793d8cde2b9ab22224569f
4
- data.tar.gz: 1f40cf797f093630f70b1ccaa5fbe4b9592d868f
3
+ metadata.gz: 7076a2b1bd0f717ca958885555c1531b1e4fbd51
4
+ data.tar.gz: 7a55f90047f4e7be60d56b6a180ad49318f60f71
5
5
  SHA512:
6
- metadata.gz: 792fefe5b95aecb79d41fd1fa3a64cde662f5089a43d978243557ac6c4175632286ee69a1dbc4db519869002cbf3aa8326a073e2407a24cb587e387616170974
7
- data.tar.gz: 140e30aebb67d5b6459202b8651b7839088d26fef5f61f4b62dab27e82cd738414a6a8504c0197ea114cb7fed934d5803d119b9fac3c2922901fa565b7ba9154
6
+ metadata.gz: cc13d3e60b303fc0e27cd0354d20f03ffd04c14a4e65b81a776c02b6c9bc9a6634279005fdefe6150d938c7d4e1ac9d8f9f7ca5112db6343b743f228875d42dc
7
+ data.tar.gz: 545f83252bb3049771b7066141985acc0db52a40391bfe287cce3e5f876e25d3133980a0cb3f144ab3a3da5677f3c9a91b8c592b0fab80c1084905cce9b43869
@@ -1,5 +1,5 @@
1
1
  module Vx
2
2
  module Common
3
- VERSION = "0.2.0.pre31"
3
+ VERSION = "0.2.0.pre32"
4
4
  end
5
5
  end
@@ -47,7 +47,7 @@ module Vx
47
47
  def template(key_location)
48
48
  key = key_location ? "-i #{key_location}" : ""
49
49
  out = ['#!/bin/sh']
50
- out << "exec /usr/bin/ssh -A -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null #{key} $@"
50
+ out << "exec /usr/bin/ssh -A -o LogLevel=quiet -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null #{key} $@"
51
51
  out.join "\n"
52
52
  end
53
53
  end
data/lib/vx/scm/git.rb CHANGED
@@ -10,7 +10,7 @@ module Vx
10
10
 
11
11
  COMMIT_RE = /^(.*) -:- (.*) \((.*)\) -:- (.*)$/
12
12
 
13
- attr_reader :src, :sha, :path, :logger, :git_ssh, :branch
13
+ attr_reader :src, :sha, :path, :logger, :git_ssh, :branch, :pull_request_id
14
14
 
15
15
  def initialize(src, sha, path, options = {}, &block)
16
16
  @src = src
@@ -18,6 +18,7 @@ module Vx
18
18
  @path = path
19
19
  @branch = options[:branch]
20
20
  @git_ssh = GitSSH.new options[:deploy_key]
21
+ @pull_request_id = options[:pull_request_id]
21
22
  @logger = block
22
23
  end
23
24
 
@@ -40,22 +41,25 @@ module Vx
40
41
  def make_fetch_command(options = {})
41
42
  depth = options.key?(:depth) ? options[:depth] : 50
42
43
  clone_branch = " --branch=#{branch}" if branch
43
- clone_cmd = "git clone -q --depth=#{depth}#{clone_branch} #{src} #{path}"
44
44
  checkout_cmd = "git checkout -qf #{sha}"
45
- fetch_cmd = "git fetch -q origin"
46
- cmd = %{
47
- if [ -d #{path}/.git ] ; then
48
- echo "$ #{fetch_cmd}" &&
49
- cd #{path} &&
50
- #{fetch_cmd} || exit $? ;
51
- else
52
- echo "$ #{clone_cmd}" &&
53
- #{clone_cmd} || exit $? ;
54
- fi ;
55
- echo "$ #{checkout_cmd}" &&
56
- cd #{path} &&
57
- #{checkout_cmd}
58
- }.gsub("\n", ' ').gsub(/\ +/, ' ').strip
45
+ fetch_cmd = nil
46
+
47
+ if pull_request_id
48
+ clone_branch = ""
49
+ fetch_cmd = "git fetch origin +refs/pull/#{pull_request_id}/merge:"
50
+ checkout_cmd = "git checkout -q FETCH_HEAD"
51
+ end
52
+
53
+ clone_cmd = "git clone -q --depth=#{depth}#{clone_branch} #{src} #{path}"
54
+
55
+ cmd = []
56
+ cmd << %{ echo "$ #{clone_cmd}" && #{clone_cmd} }
57
+ cmd << %{ cd #{path} }
58
+ cmd << %{ echo "$ #{fetch_cmd}" && #{fetch_cmd} } if fetch_cmd
59
+ cmd << %{ echo "$ #{checkout_cmd}" && #{checkout_cmd} }
60
+
61
+ cmd = cmd.join(" && ").gsub("\n", ' ').gsub(/\ +/, ' ').strip
62
+ puts "---> #{cmd}"
59
63
  cmd
60
64
  end
61
65
 
@@ -60,11 +60,6 @@ describe Vx::SCM::Git do
60
60
  expect(output).to match(Regexp.escape "$ git clone -q --depth=50 #{src} #{path}")
61
61
  end
62
62
 
63
- context "twice" do
64
- before { git.fetch }
65
- it { should eq 0 }
66
- end
67
-
68
63
  context "with error" do
69
64
  let(:src) { "/not-exists-repo.git" }
70
65
 
@@ -104,15 +99,6 @@ describe Vx::SCM::Git do
104
99
  end
105
100
  end
106
101
 
107
- context "twice" do
108
- it "should be" do
109
- code = git.open do
110
- spawn(git_ssh_env, git.make_fetch_command, &method(:add_to_output))
111
- end
112
- expect(code).to eq 0
113
- end
114
- end
115
-
116
102
  context "with error" do
117
103
  let(:src) { "/not-exists-repo.git" }
118
104
 
@@ -147,7 +133,20 @@ describe Vx::SCM::Git do
147
133
  it "should export repo" do
148
134
  expect(File.readable? "#{to}/Gemfile").to be_true
149
135
  end
136
+
137
+ context "run with pull_request" do
138
+ let(:options) { { deploy_key: deploy_key, pull_request_id: 1 } }
139
+
140
+ it "should be success" do
141
+ expect($?.to_i).to eq 0
142
+ end
143
+
144
+ it "should export repo" do
145
+ expect(File.readable? "#{to}/Gemfile").to be_true
146
+ end
147
+ end
150
148
  end
149
+
151
150
  end
152
151
 
153
152
  context "commit_info" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vx-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.pre31
4
+ version: 0.2.0.pre32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Galinsky