depengine 3.0.19 → 3.0.20

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: d0335b4baa151afe9e99277c7b6768d2056fb914
4
- data.tar.gz: 474947ac8778ee612404341afefc026533a11e3d
3
+ metadata.gz: 80a1e552180801be141930fb42d7ccf0b298ebde
4
+ data.tar.gz: 96d44887c4a629e516b268d7aa03ef496da0c7bc
5
5
  SHA512:
6
- metadata.gz: c03a1a4de62c95267685aaa98cba364e3234771f6bc390fe24f3d5005bc0233039528324396a9738f606932651bd4fe20e590a0578f2b690c9d2ee17dfbb7de7
7
- data.tar.gz: f51e87ed96162c462eddec28926355db3c5970dea03a48760885e898d35db5e7c9d9c7472735fbc75c611ac10009ad1dd13560083e1412a651bcbc9062081fa8
6
+ metadata.gz: 34787500598a6ab6d89c942ed198d1c1c68e4574138c01f6764eaa50447ee1e7cf3f38d5db5402bf38067e8c8f5fa56a479c82cbdd2a98026c86237f9c15e1d4
7
+ data.tar.gz: 1099a7b739b491455d94756f0727010528eb7080975ada5aa499ff5bef30157e012cf2e9252ff13f85bcfbbbcab51e6f21525469d11145d45785990de36f446c
@@ -80,11 +80,33 @@ module Deployment
80
80
  :from => options[:deploy_email_from] || @cdb['deploy_email_from'],
81
81
  :to => options[:deploy_email_to] || @cdb['deploy_email_to'],
82
82
  :subject => "#{options[:env]} #{options[:job_name]} #{options[:module_name]} #{options[:application_name]} #{options[:version]} #{options[:status]}",
83
- :body => "Env: #{options[:env]}\nJob: #{options[:job_name]}\nModule: #{options[:module_name]}\nApplication: #{options[:application_name]}\nVersion: #{options[:version].to_json}\n#{options[:status]}.\n\n---\nx#{options[:message]}"
83
+ :body => "Env: #{options[:env]}\nJob: #{options[:job_name]}\nModule: #{options[:module_name]}\nApplication: #{options[:application_name]}\nVersion: #{options[:version].to_json}\n#{options[:status]}.\n\n#{options[:message]}"
84
84
  }
85
85
  sendmail(mail_options)
86
86
  end
87
87
 
88
+ # Sends an email with git commit history to report a deployment to a given recepiant.
89
+ #
90
+ # Parameters:
91
+ # * +:r2+ - Include commits that are reachable from r2
92
+ # * +:r1+ - but exclude those that are reachable from r1.
93
+ # * +options+ - a hash with needed configuration options for the email. All parameters are optional.
94
+ # * +:git_dir+ - Directory from which the git repo can be reached (the one containing .git or any of its children).
95
+ # * +:application_name+ - which application has been deployed
96
+ # * +:module_name+ - which module of the application has been deployed
97
+ # * +:status+ - the resulting status of the deployment
98
+ # * +:message+ - a additional message to send in the mail, commonly used to specify any non positive status.
99
+ # * +:deploy_email_from+ - the senders address
100
+ # * +:deploy_email_to+ - the recipiants address
101
+ # Please see `GITREVISIONS(7)` for more info on how to specify a revision range.
102
+ def report_by_mail_with_git_history(r1='', r2='', options={})
103
+ git = Provider::Git.new
104
+ git.repository_local_dir = options[:git_dir] || '.'
105
+ options[:message] = (options[:message] || '') + git.history(r1, r2).to_s
106
+
107
+ report_by_mail(options)
108
+ end
109
+
88
110
  # Deploys a tomcat based application to a set of app servers. <br>
89
111
  # The tomcats are restarted in this process.
90
112
  #
@@ -104,6 +104,21 @@ module Provider
104
104
  end
105
105
  end
106
106
  end
107
+
108
+ # Gets the git commit history of a local git repository.
109
+ #
110
+ # Parameters:
111
+ # * +:r2+ - Include commits that are reachable from r2
112
+ # * +:r1+ - but exclude those that are reachable from r1.
113
+ # Please see `GITREVISIONS(7)` for more info on how to specify a revision range.
114
+ def history(r1='',r2='HEAD')
115
+ rev_range = r1.empty? ? '' : "#{r1}..#{r2}"
116
+
117
+ Dir.chdir(@repository_local_dir) do
118
+ Processor.local_execute(["git log --oneline #{rev_range}"])
119
+ end
120
+ end
121
+
107
122
  end
108
123
  end
109
124
 
@@ -1,3 +1,3 @@
1
1
  module Depengine
2
- VERSION = "3.0.19"
2
+ VERSION = "3.0.20"
3
3
  end
@@ -0,0 +1,31 @@
1
+ require_relative '../lib/depengine/provider/git'
2
+ require_relative '../lib/depengine/processor/local_execute'
3
+
4
+ describe '#history' do
5
+
6
+ let(:git) { g = Provider::Git.new; g.repository_local_dir = '.'; g }
7
+
8
+ context 'no parameters given' do
9
+ it 'falls back to all history' do
10
+ expect(Processor).to receive(:local_execute).once.with(['git log --oneline ']).and_return('ok')
11
+ git.history()
12
+ end
13
+ end
14
+
15
+ context 'one revision given' do
16
+ it 'falls back to history between HEAD and given revision' do
17
+ r1 = '4223abc'
18
+ expect(Processor).to receive(:local_execute).once.with(['git log --oneline 4223abc..HEAD']).and_return('ok')
19
+ git.history(r1)
20
+ end
21
+ end
22
+
23
+ context 'two revisions given' do
24
+ it 'uses both to get commits betweem them' do
25
+ r1, r2 = '4223abc', 'caffe42'
26
+ expect(Processor).to receive(:local_execute).once.with(['git log --oneline 4223abc..caffe42']).and_return('ok')
27
+ git.history(r1,r2)
28
+ end
29
+ end
30
+
31
+ end
@@ -145,4 +145,25 @@ describe "the report_by_mail method" do
145
145
  worker.report_by_mail(h)
146
146
  end
147
147
 
148
+ describe '#report_by_mail_with_git_history' do
149
+ it 'does include the git history in the message object' do
150
+ worker = Deployment::Worker.new
151
+ h = {
152
+ :application_name => "testapplication",
153
+ :module_name => "testmodule",
154
+ :job_name => "testjob",
155
+ :status => "SUCCESS",
156
+ :message => "i dont know what could possibly go wrong",
157
+ :deploy_email_from => "#{ENV['USER']}@localhost",
158
+ :deploy_email_to => "#{ENV['USER']}@localhost"
159
+ }
160
+ git_history = "825dc42 foo improved\ne626123 bar renamed\n"
161
+ allow(Processor).to receive(:local_execute).and_return(git_history)
162
+ expect(worker).to receive(:report_by_mail).once.with(
163
+ h.merge({:message => h[:message]+git_history})
164
+ )
165
+ worker.report_by_mail_with_git_history('', '', h)
166
+ end
167
+ end
168
+
148
169
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: depengine
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.19
4
+ version: 3.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Automatisierung
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-30 00:00:00.000000000 Z
11
+ date: 2014-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -267,6 +267,7 @@ files:
267
267
  - spec/demo_recipe/recipes/demo.rb
268
268
  - spec/deployhelper_spec.rb
269
269
  - spec/fileops_spec.rb
270
+ - spec/git_spec.rb
270
271
  - spec/helper_spec.rb
271
272
  - spec/junit.rb
272
273
  - spec/local_execute.rb