vx-common 0.2.0.pre31 → 0.2.0.pre32
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 +4 -4
- data/lib/vx/common/version.rb +1 -1
- data/lib/vx/scm/git/git_ssh.rb +1 -1
- data/lib/vx/scm/git.rb +20 -16
- data/spec/lib/scm/git_spec.rb +13 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7076a2b1bd0f717ca958885555c1531b1e4fbd51
|
4
|
+
data.tar.gz: 7a55f90047f4e7be60d56b6a180ad49318f60f71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc13d3e60b303fc0e27cd0354d20f03ffd04c14a4e65b81a776c02b6c9bc9a6634279005fdefe6150d938c7d4e1ac9d8f9f7ca5112db6343b743f228875d42dc
|
7
|
+
data.tar.gz: 545f83252bb3049771b7066141985acc0db52a40391bfe287cce3e5f876e25d3133980a0cb3f144ab3a3da5677f3c9a91b8c592b0fab80c1084905cce9b43869
|
data/lib/vx/common/version.rb
CHANGED
data/lib/vx/scm/git/git_ssh.rb
CHANGED
@@ -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 =
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
#{
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
#{
|
58
|
-
}
|
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
|
|
data/spec/lib/scm/git_spec.rb
CHANGED
@@ -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
|