evrone-ci-common 0.0.6 → 0.0.7

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: 8b17b5c76d7046f2b5f0bc3b022c255f3376fac0
4
- data.tar.gz: 2b2461bb491dc87af1532d58e6631b4df8c5732b
3
+ metadata.gz: e833f784c332a5c8869427a5b56a0f1a379bf192
4
+ data.tar.gz: e6400620531bf10a5b79316774695c870a804e4b
5
5
  SHA512:
6
- metadata.gz: a8203fd0db2e58212d74b509102355766e496baccd6fcbf767d9f32b8b090e0bc55a14492bc067a0cb54f724015f3d73030bc06d7463f7338ab9d57570f983f7
7
- data.tar.gz: 6ade35c3184be60a0e3f21f0ff17ce905af51d0a3197333502cc41bf20f6cd1b381ed0eff5eb8b0e1c33df98e8d920bb8095dc314cc1a3640aaf5b2b46a95586
6
+ metadata.gz: 271322ba63da3c438165dab37685869771d6d1410382fc5cbf98074eb4318216ff7c7d7f638bca2f9f424ee73485f22474f8cd3c68c9d5596473110748d18772
7
+ data.tar.gz: 1679bed77958ddc617430a0331fb2f34187705e4daab8149eb38b42e6d9136c30432fc7fed33deac6d50263b3426341b859dfd097829ea00dbf3495a8e993677
data/Rakefile CHANGED
@@ -1,3 +1,6 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.require
1
4
  require "bundler/gem_tasks"
2
5
  require 'rspec/core/rake_task'
3
6
 
@@ -1,7 +1,7 @@
1
1
  module Evrone
2
2
  module CI
3
3
  module Common
4
- VERSION = "0.0.6"
4
+ VERSION = "0.0.7"
5
5
  end
6
6
  end
7
7
  end
@@ -14,9 +14,9 @@ module Evrone
14
14
 
15
15
  end
16
16
 
17
- module CSM
17
+ module SCM
18
18
 
19
- autoload :Git, File.expand_path("../csm/git", __FILE__)
19
+ autoload :Git, File.expand_path("../scm/git", __FILE__)
20
20
 
21
21
  end
22
22
 
@@ -1,6 +1,6 @@
1
1
  module Evrone
2
2
  module CI
3
- module CSM
3
+ module SCM
4
4
 
5
5
  class Git
6
6
 
@@ -3,7 +3,7 @@ require File.expand_path("../git/git_ssh", __FILE__)
3
3
 
4
4
  module Evrone
5
5
  module CI
6
- module CSM
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
- def commit_info_string
54
- output = ""
55
- code = spawn commit_info_cmd, chdir: path do |io|
56
- output << io
57
- end
58
- if code == 0
59
- output.strip
60
- else
61
- nil
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
- def commit_info_cmd
66
- %{git log -1 --pretty=format:'%H -:- %cn (%ce) -:- %s'}
67
- end
69
+ def commit_info_cmd
70
+ %{git log -1 --pretty=format:'%H -:- %cn (%ce) -:- %s'}
71
+ end
68
72
 
69
- def repo_exist?
70
- File.directory?(path.to_s + "/.git")
71
- end
73
+ def repo_exist?
74
+ File.directory?(path.to_s + "/.git")
75
+ end
72
76
 
73
- def update
74
- run_git 'git fetch origin', chdir: path
75
- end
77
+ def update
78
+ run_git 'git fetch origin', chdir: path
79
+ end
76
80
 
77
- def clone
78
- run_git "git clone -q '#{src}' '#{path}'"
79
- end
81
+ def clone
82
+ run_git "git clone -q #{src} #{path}"
83
+ end
80
84
 
81
- def checkout
82
- run_git "git checkout -qf #{sha}", chdir: path
83
- end
85
+ def checkout
86
+ run_git "git checkout -qf #{sha}", chdir: path
87
+ end
84
88
 
85
- def run_git(cmd, options = {})
86
- env = {
87
- 'GIT_SSH' => git_ssh.location.path
88
- }
89
- logger.call "$ #{cmd}\n"
90
- spawn(env, cmd, options, &logger)
91
- end
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::CSM::Git do
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 deirectories and checkout sha" do
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 '#{src}' '#{path}'\n$ git checkout -qf #{sha}\n"
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.6
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/csm/git.rb
133
- - lib/evrone/ci/csm/git/git_ssh.rb
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/csm/git_spec.rb
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/csm/git_spec.rb
167
+ - spec/lib/scm/git_spec.rb
168
168
  - spec/spec_helper.rb
169
- has_rdoc: