From ab5a5ddc3e0c394751d538be0aea82efffcf2ddd Mon Sep 17 00:00:00 2001 From: Priya Rani Date: Thu, 11 Jan 2024 14:25:15 +0530 Subject: [PATCH] OTWO-6969 Store commit_sha instead of diffs in logfile (#147) * OTWO-6969 Store commit_sha instead of diffs in logfile * Check for expensive commit_count * Update whatchanged method * Fix test * Handle PR comments * Update version --- lib/ohloh_scm/git/activity.rb | 21 ++++++++++++++++----- lib/ohloh_scm/version.rb | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/ohloh_scm/git/activity.rb b/lib/ohloh_scm/git/activity.rb index 0146e772..bac59c7e 100644 --- a/lib/ohloh_scm/git/activity.rb +++ b/lib/ohloh_scm/git/activity.rb @@ -58,9 +58,15 @@ def each_commit(opts = {}) # For OpenHub, this is fine because OpenHub ignores merge diffs anyway. previous = nil safe_open_log_file(opts) do |io| - OhlohScm::GitParser.parse(io) do |e| - yield fixup_null_merge(e) unless previous && previous.token == e.token - previous = e + if ENV['EXPENSIVE_COMMIT_COUNT'] && commit_count(opts) > ENV['EXPENSIVE_COMMIT_COUNT'].to_i + io.each do |commit_sha| + yield verbose_commit(commit_sha.chomp) + end + else + OhlohScm::GitParser.parse(io) do |e| + yield fixup_null_merge(e) unless previous && previous.token == e.token + previous = e + end end end end @@ -177,8 +183,13 @@ def safe_open_log_file(opts = {}) end def open_log_file(opts) - run "#{rev_list_command(opts)} | xargs -n 1 #{OhlohScm::GitParser.whatchanged}"\ - " | #{string_encoder_path} > #{log_filename}" + if ENV['EXPENSIVE_COMMIT_COUNT'] && commit_count(opts) > ENV['EXPENSIVE_COMMIT_COUNT'].to_i + cmd = "#{rev_list_command(opts)} > #{log_filename}" + else + cmd = "#{rev_list_command(opts)} | xargs -n 1 #{OhlohScm::GitParser.whatchanged}"\ + " | #{string_encoder_path} > #{log_filename}" + end + run(cmd) File.open(log_filename, 'r') { |io| yield io } ensure File.delete(log_filename) if File.exist?(log_filename) diff --git a/lib/ohloh_scm/version.rb b/lib/ohloh_scm/version.rb index 197558ff..0f806b7b 100644 --- a/lib/ohloh_scm/version.rb +++ b/lib/ohloh_scm/version.rb @@ -2,7 +2,7 @@ module OhlohScm module Version - STRING = '4.0.2' + STRING = '4.0.3' GIT = '2.34.1' SVN = '1.14.1' CVSNT = '1.12.13'