From 264d5e057281914d0cf26046204f35b710b8e53a Mon Sep 17 00:00:00 2001 From: Yurii Dubinka Date: Wed, 25 Nov 2020 22:43:47 +0200 Subject: [PATCH] #262: Directory not empty @ dir_s_rmdir Fixed #262 --- lazylead.gemspec | 2 +- lib/lazylead/task/svn/diff.rb | 24 ++++++++++++++++-------- lib/messages/svn_diff.erb | 18 +++++++++--------- lib/messages/svn_diff_attachment.erb | 2 +- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/lazylead.gemspec b/lazylead.gemspec index e18272e..a8d1e55 100755 --- a/lazylead.gemspec +++ b/lazylead.gemspec @@ -70,8 +70,8 @@ tasks instead of solving technical problems." s.add_runtime_dependency "rufus-scheduler", "3.6.0" s.add_runtime_dependency "slop", "4.4" s.add_runtime_dependency "sqlite3", "1.4.2" + s.add_runtime_dependency "tempfile", "0.1.0" s.add_runtime_dependency "tilt", "2.0.10" - s.add_runtime_dependency "tmpdir", "0.1.0" s.add_runtime_dependency "tzinfo", "1.1" s.add_runtime_dependency "tzinfo-data", "1.2019.3" s.add_runtime_dependency "vcs4sql", "0.1.0" diff --git a/lib/lazylead/task/svn/diff.rb b/lib/lazylead/task/svn/diff.rb index 295cd32..c85b946 100644 --- a/lib/lazylead/task/svn/diff.rb +++ b/lib/lazylead/task/svn/diff.rb @@ -22,7 +22,7 @@ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE # OR OTHER DEALINGS IN THE SOFTWARE. -require "tmpdir" +require "tempfile" require "nokogiri" require "backtrace" require "active_support/core_ext/hash/conversions" @@ -59,18 +59,26 @@ def send_email(stdout, postman, opts) Dir.mktmpdir do |dir| name = "svn-log-#{Date.today.strftime('%d-%b-%Y')}.html" f = File.open(File.join(dir, name), "w") - f.write( - Email.new( - opts["template-attachment"], - opts.merge(stdout: stdout, version: Lazylead::VERSION) - ).render - ) - postman.send opts.merge(stdout: stdout, attachments: [f.path]) + begin + f.write make_attachment(stdout, opts) + f.close + postman.send opts.merge(stdout: stdout, attachments: [f.path]) + ensure + File.delete(f) + end rescue StandardError => e @log.error "ll-010: Can't send an email for #{opts} due to " \ "#{Backtrace.new(e)}' based on #{stdout}'" end end + + # Assemble HTML for attachment based on SVN output + def make_attachment(stdout, opts) + Email.new( + opts["template-attachment"], + opts.merge(stdout: stdout, version: Lazylead::VERSION) + ).render + end end end end diff --git a/lib/messages/svn_diff.erb b/lib/messages/svn_diff.erb index e18a3c6..f171e8f 100644 --- a/lib/messages/svn_diff.erb +++ b/lib/messages/svn_diff.erb @@ -77,7 +77,7 @@ .commit * { padding-left: 4px; font-size: 8px; - line-height: 15px; + line-height: 12px; } SVN log @@ -89,17 +89,17 @@ <% stdout.split("------------------------------------------------------------------------").reject(&:blank?).reverse.each do |commit| %>
<% commit.split("\n").reject(&:blank?).each_with_index do |line, index| %> - <% if index.zero? %> - <% details = line.split("|").map(&:strip).reject(&:blank?) %> -

+

+ <% if index.zero? %> + <% details = line.split("|").map(&:strip).reject(&:blank?) %> <%= details[0] %> by <%= details[1] %> at <%= details[2] %> -

- <% end %> - <% if index == 1 %> -

<%= line %>

- <% end %> + <% end %> + <% if index == 1 %> + <%= line %> + <% end %> +

<% end %>
<% end %> diff --git a/lib/messages/svn_diff_attachment.erb b/lib/messages/svn_diff_attachment.erb index d526075..31c99db 100644 --- a/lib/messages/svn_diff_attachment.erb +++ b/lib/messages/svn_diff_attachment.erb @@ -108,7 +108,7 @@ <% end %> <% end %> -


+
<% end %>

Posted by lazylead v<%= version %>.