Skip to content

Commit

Permalink
OTWO-6969 Store commit_sha instead of diffs in logfile (#147)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Priya Rani authored Jan 11, 2024
1 parent 78915cf commit ab5a5dd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions lib/ohloh_scm/git/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/ohloh_scm/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit ab5a5dd

Please sign in to comment.