evrone-ci-common 0.0.6 → 0.0.7
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/Rakefile +3 -0
- data/lib/evrone/ci/common/version.rb +1 -1
- data/lib/evrone/ci/common.rb +2 -2
- data/lib/evrone/ci/{csm → scm}/git/git_ssh.rb +1 -1
- data/lib/evrone/ci/{csm → scm}/git.rb +37 -33
- data/spec/lib/{csm → scm}/git_spec.rb +45 -3
- metadata +5 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e833f784c332a5c8869427a5b56a0f1a379bf192
|
|
4
|
+
data.tar.gz: e6400620531bf10a5b79316774695c870a804e4b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 271322ba63da3c438165dab37685869771d6d1410382fc5cbf98074eb4318216ff7c7d7f638bca2f9f424ee73485f22474f8cd3c68c9d5596473110748d18772
|
|
7
|
+
data.tar.gz: 1679bed77958ddc617430a0331fb2f34187705e4daab8149eb38b42e6d9136c30432fc7fed33deac6d50263b3426341b859dfd097829ea00dbf3495a8e993677
|
data/Rakefile
CHANGED
data/lib/evrone/ci/common.rb
CHANGED
|
@@ -3,7 +3,7 @@ require File.expand_path("../git/git_ssh", __FILE__)
|
|
|
3
3
|
|
|
4
4
|
module Evrone
|
|
5
5
|
module CI
|
|
6
|
-
module
|
|
6
|
+
module SCM
|
|
7
7
|
|
|
8
8
|
class Git
|
|
9
9
|
|
|
@@ -33,6 +33,10 @@ module Evrone
|
|
|
33
33
|
%{ (cd '#{from}' && git checkout-index -a -f --prefix='#{to}/') }.strip
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
def make_fetch_command
|
|
37
|
+
%{ (test -d #{path} || git clone -q #{src} #{path}) && cd #{path} && git checkout -qf #{sha} }.strip
|
|
38
|
+
end
|
|
39
|
+
|
|
36
40
|
def commit_info
|
|
37
41
|
rs = {}
|
|
38
42
|
if str = commit_info_string
|
|
@@ -50,45 +54,45 @@ module Evrone
|
|
|
50
54
|
|
|
51
55
|
private
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
def commit_info_string
|
|
58
|
+
output = ""
|
|
59
|
+
code = spawn commit_info_cmd, chdir: path do |io|
|
|
60
|
+
output << io
|
|
61
|
+
end
|
|
62
|
+
if code == 0
|
|
63
|
+
output.strip
|
|
64
|
+
else
|
|
65
|
+
nil
|
|
66
|
+
end
|
|
62
67
|
end
|
|
63
|
-
end
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
def commit_info_cmd
|
|
70
|
+
%{git log -1 --pretty=format:'%H -:- %cn (%ce) -:- %s'}
|
|
71
|
+
end
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
def repo_exist?
|
|
74
|
+
File.directory?(path.to_s + "/.git")
|
|
75
|
+
end
|
|
72
76
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
def update
|
|
78
|
+
run_git 'git fetch origin', chdir: path
|
|
79
|
+
end
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
def clone
|
|
82
|
+
run_git "git clone -q #{src} #{path}"
|
|
83
|
+
end
|
|
80
84
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
def checkout
|
|
86
|
+
run_git "git checkout -qf #{sha}", chdir: path
|
|
87
|
+
end
|
|
84
88
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
def run_git(cmd, options = {})
|
|
90
|
+
env = {
|
|
91
|
+
'GIT_SSH' => git_ssh.location.path
|
|
92
|
+
}
|
|
93
|
+
logger.call "$ #{cmd}\n"
|
|
94
|
+
spawn(env, cmd, options, &logger)
|
|
95
|
+
end
|
|
92
96
|
|
|
93
97
|
end
|
|
94
98
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
require 'evrone/ci/message/testing'
|
|
3
3
|
|
|
4
|
-
describe Evrone::CI::
|
|
4
|
+
describe Evrone::CI::SCM::Git do
|
|
5
5
|
let(:path) { '/tmp/.test/repo' }
|
|
6
6
|
let(:message) { Evrone::CI::Message::PerformBuild.test_message }
|
|
7
7
|
let(:src) { message.src }
|
|
@@ -29,7 +29,7 @@ describe Evrone::CI::CSM::Git do
|
|
|
29
29
|
|
|
30
30
|
it { should eq 0 }
|
|
31
31
|
|
|
32
|
-
it "should create nessesary
|
|
32
|
+
it "should create nessesary directories and checkout sha" do
|
|
33
33
|
subject
|
|
34
34
|
expect(File.directory? path).to be
|
|
35
35
|
expect(File.directory? "#{path}/.git").to be
|
|
@@ -40,7 +40,7 @@ describe Evrone::CI::CSM::Git do
|
|
|
40
40
|
|
|
41
41
|
it "should capture output" do
|
|
42
42
|
subject
|
|
43
|
-
expect(output).to eq "$ git clone -q
|
|
43
|
+
expect(output).to eq "$ git clone -q #{src} #{path}\n$ git checkout -qf #{sha}\n"
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
context "twice" do
|
|
@@ -58,6 +58,48 @@ describe Evrone::CI::CSM::Git do
|
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
+
context "make_fetch_command" do
|
|
62
|
+
include Evrone::Common::Spawn
|
|
63
|
+
|
|
64
|
+
let(:run) { spawn(git.make_fetch_command) {|o| puts o } }
|
|
65
|
+
subject { git.make_fetch_command }
|
|
66
|
+
|
|
67
|
+
before do
|
|
68
|
+
run
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it { should eq "(test -d #{path} || git clone -q #{src} #{path}) && cd #{path} && git checkout -qf #{sha}" }
|
|
72
|
+
|
|
73
|
+
it "should be success" do
|
|
74
|
+
expect(run).to eq 0
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should create nessesary directories and checkout sha" do
|
|
78
|
+
expect(File.directory? path).to be
|
|
79
|
+
expect(File.directory? "#{path}/.git").to be
|
|
80
|
+
Dir.chdir path do
|
|
81
|
+
expect((`git rev-parse HEAD`).strip).to eq sha
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context "twice" do
|
|
86
|
+
it "should be" do
|
|
87
|
+
code = spawn subject do |o|
|
|
88
|
+
puts o.inspect
|
|
89
|
+
end
|
|
90
|
+
expect(code).to eq 0
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
context "with error" do
|
|
95
|
+
let(:src) { "/not-exists-repo.git" }
|
|
96
|
+
|
|
97
|
+
it "should return 128 exitstatus and add error to output" do
|
|
98
|
+
expect(run).to eq 128
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
61
103
|
context ".make_export_command" do
|
|
62
104
|
let(:from) { path }
|
|
63
105
|
let(:to) { '/tmp/.test/export' }
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: evrone-ci-common
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Galinsky
|
|
@@ -129,12 +129,12 @@ files:
|
|
|
129
129
|
- lib/evrone/ci/common/perform_message_wrapper.rb
|
|
130
130
|
- lib/evrone/ci/common/tagged_logging.rb
|
|
131
131
|
- lib/evrone/ci/common/version.rb
|
|
132
|
-
- lib/evrone/ci/
|
|
133
|
-
- lib/evrone/ci/
|
|
132
|
+
- lib/evrone/ci/scm/git.rb
|
|
133
|
+
- lib/evrone/ci/scm/git/git_ssh.rb
|
|
134
134
|
- spec/lib/common/helper/middlewares_spec.rb
|
|
135
135
|
- spec/lib/common/helper/shell_spec.rb
|
|
136
136
|
- spec/lib/common/perform_message_wrapper_spec.rb
|
|
137
|
-
- spec/lib/
|
|
137
|
+
- spec/lib/scm/git_spec.rb
|
|
138
138
|
- spec/spec_helper.rb
|
|
139
139
|
homepage: ''
|
|
140
140
|
licenses:
|
|
@@ -164,6 +164,5 @@ test_files:
|
|
|
164
164
|
- spec/lib/common/helper/middlewares_spec.rb
|
|
165
165
|
- spec/lib/common/helper/shell_spec.rb
|
|
166
166
|
- spec/lib/common/perform_message_wrapper_spec.rb
|
|
167
|
-
- spec/lib/
|
|
167
|
+
- spec/lib/scm/git_spec.rb
|
|
168
168
|
- spec/spec_helper.rb
|
|
169
|
-
has_rdoc:
|