ohloh_scm 4.0.2 → 4.0.4

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
  SHA256:
3
- metadata.gz: 5f538e2a92d3ffd83e0aa764ee8bc326d052f5a6dcb506f43161fb98caf47da1
4
- data.tar.gz: 4cbefaed2f73fc9df835b2ed99ac09aae1bda3ddbae8beaafea543517ce578fa
3
+ metadata.gz: 8a2809f103f847130e35e67a70e1d8faf67a411a1fa94833bdb31c96bc771333
4
+ data.tar.gz: 180fdb5edbb2bfee8ce634aa00a8ea870c4c079f9680eabe2eb99c10a8bf9c2e
5
5
  SHA512:
6
- metadata.gz: cac9e0147efe5bb98038fa0b957b8dae365af35349075046b32345bc448afdbb7047233fa36da9b85eb3e9a38a0213acb04273535c4dd9f72280f84a0c8dce8c
7
- data.tar.gz: 7658681a1a5cbe76e3cf29dc712313affb063cdc6aaf99330fee177a8b91039bf446b0a421425b3cffa9ec21b84000c0a940dd3777a07a3914ca6f352abd9755
6
+ metadata.gz: 80f56ed86d0187d93893d69125369a822f09fa3635d7e386639bfb4d114ce326dad5b0cfd489e38d6cc57feee717dffd78d658cee70bfe11f4fce5944a4d5fd4
7
+ data.tar.gz: 95828cac55d0d3ed5e57e7b3b067e94bdfab59f3f9365f6f3cd95dfbd622ddb020002ffba8c7652c2120a91630312a5dee21d07e8b3b71a36a7419d59b2996b4
@@ -58,9 +58,15 @@ module OhlohScm
58
58
  # For OpenHub, this is fine because OpenHub ignores merge diffs anyway.
59
59
  previous = nil
60
60
  safe_open_log_file(opts) do |io|
61
- OhlohScm::GitParser.parse(io) do |e|
62
- yield fixup_null_merge(e) unless previous && previous.token == e.token
63
- previous = e
61
+ if ENV['EXPENSIVE_COMMIT_COUNT'] && commit_count(opts) > ENV['EXPENSIVE_COMMIT_COUNT'].to_i
62
+ io.each do |commit_sha|
63
+ yield verbose_commit(commit_sha.chomp)
64
+ end
65
+ else
66
+ OhlohScm::GitParser.parse(io) do |e|
67
+ yield fixup_null_merge(e) unless previous && previous.token == e.token
68
+ previous = e
69
+ end
64
70
  end
65
71
  end
66
72
  end
@@ -177,8 +183,13 @@ module OhlohScm
177
183
  end
178
184
 
179
185
  def open_log_file(opts)
180
- run "#{rev_list_command(opts)} | xargs -n 1 #{OhlohScm::GitParser.whatchanged}"\
181
- " | #{string_encoder_path} > #{log_filename}"
186
+ if ENV['EXPENSIVE_COMMIT_COUNT'] && commit_count(opts) > ENV['EXPENSIVE_COMMIT_COUNT'].to_i
187
+ cmd = "#{rev_list_command(opts)} > #{log_filename}"
188
+ else
189
+ cmd = "#{rev_list_command(opts)} | xargs -n 1 #{OhlohScm::GitParser.whatchanged}"\
190
+ " | #{string_encoder_path} > #{log_filename}"
191
+ end
192
+ run(cmd)
182
193
  File.open(log_filename, 'r') { |io| yield io }
183
194
  ensure
184
195
  File.delete(log_filename) if File.exist?(log_filename)
@@ -5,7 +5,7 @@ module OhlohScm
5
5
  class Scm < OhlohScm::Scm
6
6
  def initialize(core:, url:, branch_name:, username:, password:)
7
7
  super
8
- @branch_name = branch_name || 'master'
8
+ @branch_name = branch_name
9
9
  end
10
10
 
11
11
  # == Example:
@@ -28,6 +28,10 @@ module OhlohScm
28
28
  run "cd #{url} && git checkout $(git ls-files #{filenames})"
29
29
  end
30
30
 
31
+ def branch_name_or_default
32
+ branch_name || 'master'
33
+ end
34
+
31
35
  private
32
36
 
33
37
  def clone_or_fetch(remote_scm, callback)
@@ -8,6 +8,13 @@ module OhlohScm
8
8
 
9
9
  activity.branches.include?(name)
10
10
  end
11
+
12
+ def default_branch
13
+ return scm.branch_name_or_default unless exist?
14
+
15
+ name = run("git remote show '#{scm.url}' | grep 'HEAD branch' | awk '{print $3}'").strip
16
+ name.to_s.empty? ? scm.branch_name_or_default : name
17
+ end
11
18
  end
12
19
  end
13
20
  end
@@ -21,5 +21,7 @@ module OhlohScm
21
21
  def scm_dir_exist?
22
22
  Dir.exist?(scm.vcs_path)
23
23
  end
24
+
25
+ def default_branch; end
24
26
  end
25
27
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module OhlohScm
4
4
  module Version
5
- STRING = '4.0.2'
5
+ STRING = '4.0.4'
6
6
  GIT = '2.34.1'
7
7
  SVN = '1.14.1'
8
8
  CVSNT = '1.12.13'
@@ -1,12 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RepositoryHelper
4
- %w[git svn git_svn cvs hg bzr].each do |scm_type|
4
+ %w[svn git_svn cvs hg bzr].each do |scm_type|
5
5
  define_method("with_#{scm_type}_repository") do |name, branch_name = nil, &block|
6
6
  with_repository(scm_type, name, branch_name) { |core| block.call(core) }
7
7
  end
8
8
  end
9
9
 
10
+ def with_git_repository(name, branch_name = 'master', &block)
11
+ with_repository('git', name, branch_name) { |core| block.call(core) }
12
+ end
13
+
10
14
  private
11
15
 
12
16
  def with_repository(scm_type, name, branch_name = nil)
@@ -59,7 +59,7 @@ describe 'Cvs::Activity' do
59
59
  it 'must correctly convert commits to git' do
60
60
  with_cvs_repository('cvs', 'simple') do |cvs|
61
61
  tmpdir do |tmp_dir|
62
- git_core = OhlohScm::Factory.get_core(url: tmp_dir)
62
+ git_core = OhlohScm::Factory.get_core(url: tmp_dir, branch_name: 'master')
63
63
  git_core.scm.pull(cvs.scm, TestCallback.new)
64
64
  utc_dates = ['2006-06-29 16:21:07 UTC', '2006-06-29 18:14:47 UTC',
65
65
  '2006-06-29 18:45:29 UTC', '2006-06-29 18:48:54 UTC',
@@ -329,7 +329,7 @@ describe 'Git::Activity' do
329
329
 
330
330
  it 'must commit all changes in the working directory' do
331
331
  tmpdir do |dir|
332
- core = OhlohScm::Factory.get_core(scm_type: :git, url: dir)
332
+ core = OhlohScm::Factory.get_core(scm_type: :git, branch_name: 'master', url: dir)
333
333
 
334
334
  core.activity.send(:init_db)
335
335
  refute core.activity.send(:anything_to_commit?)
@@ -356,7 +356,7 @@ describe 'Git::Activity' do
356
356
 
357
357
  it 'must test that no token returns nil' do
358
358
  tmpdir do |dir|
359
- core = OhlohScm::Factory.get_core(scm_type: :git, url: dir)
359
+ core = OhlohScm::Factory.get_core(scm_type: :git, branch_name: 'master', url: dir)
360
360
  refute core.activity.read_token
361
361
  core.activity.send(:init_db)
362
362
  refute core.activity.read_token
@@ -365,7 +365,7 @@ describe 'Git::Activity' do
365
365
 
366
366
  it 'must test write and read token' do
367
367
  tmpdir do |dir|
368
- core = OhlohScm::Factory.get_core(scm_type: :git, url: dir)
368
+ core = OhlohScm::Factory.get_core(scm_type: :git, branch_name: 'master', url: dir)
369
369
  core.activity.send(:init_db)
370
370
  core.activity.send(:write_token, 'FOO')
371
371
  refute core.activity.read_token # Token not valid until committed
@@ -376,7 +376,7 @@ describe 'Git::Activity' do
376
376
 
377
377
  it 'must test that commit_all includes write token' do
378
378
  tmpdir do |dir|
379
- core = OhlohScm::Factory.get_core(scm_type: :git, url: dir)
379
+ core = OhlohScm::Factory.get_core(scm_type: :git, branch_name: 'master', url: dir)
380
380
  core.activity.send(:init_db)
381
381
  c = OhlohScm::Commit.new
382
382
  c.token = 'BAR'
@@ -93,7 +93,7 @@ describe 'Git::Scm' do
93
93
  it 'must test the basic conversion to git' do
94
94
  with_cvs_repository('cvs', 'simple') do |src_core|
95
95
  tmpdir do |dest_dir|
96
- core = OhlohScm::Factory.get_core(scm_type: :git, url: dest_dir)
96
+ core = OhlohScm::Factory.get_core(scm_type: :git, branch_name: 'master', url: dest_dir)
97
97
  refute core.status.scm_dir_exist?
98
98
  core.scm.pull(src_core.scm, TestCallback.new)
99
99
  assert core.status.scm_dir_exist?
@@ -126,4 +126,9 @@ describe 'Git::Scm' do
126
126
  assert system("ls #{dir}/Godeps/Godeps.json > /dev/null")
127
127
  end
128
128
  end
129
+
130
+ it 'must return master when branch_name is null' do
131
+ core = OhlohScm::Factory.get_core(scm_type: :git, url: 'foobar')
132
+ _(core.scm.branch_name_or_default).must_equal 'master'
133
+ end
129
134
  end
@@ -4,8 +4,22 @@ describe 'Git::Status' do
4
4
  it 'branch?' do
5
5
  with_git_repository('git') do |git|
6
6
  git.activity.send(:branches).must_equal %w[develop master]
7
- assert git.status.branch? # checks master.
7
+ assert git.status.branch?('master')
8
8
  assert git.status.branch?('develop')
9
9
  end
10
10
  end
11
+
12
+ describe 'default_branch' do
13
+ it 'must return default branch when repository doesnt exist' do
14
+ git = OhlohScm::Factory.get_core(scm_type: :git, url: 'foobar')
15
+ git.status.stubs(:exist?)
16
+ _(git.status.default_branch).must_equal 'master'
17
+ end
18
+
19
+ it 'must return default branch when no HEAD branch is found in remote' do
20
+ git = OhlohScm::Factory.get_core(scm_type: :git, url: 'foobar')
21
+ git.status.stubs(:exist?).returns(true)
22
+ git.status.default_branch.must_equal 'master'
23
+ end
24
+ end
11
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohloh_scm
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenHub Team at Synopsys
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-04 00:00:00.000000000 Z
11
+ date: 2024-10-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  The OpenHub source control management library for \