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 +4 -4
- data/lib/ohloh_scm/git/activity.rb +16 -5
- data/lib/ohloh_scm/git/scm.rb +5 -1
- data/lib/ohloh_scm/git/status.rb +7 -0
- data/lib/ohloh_scm/status.rb +2 -0
- data/lib/ohloh_scm/version.rb +1 -1
- data/spec/helpers/repository_helper.rb +5 -1
- data/spec/ohloh_scm/cvs/activity_spec.rb +1 -1
- data/spec/ohloh_scm/git/activity_spec.rb +4 -4
- data/spec/ohloh_scm/git/scm_spec.rb +6 -1
- data/spec/ohloh_scm/git/status_spec.rb +15 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a2809f103f847130e35e67a70e1d8faf67a411a1fa94833bdb31c96bc771333
|
4
|
+
data.tar.gz: 180fdb5edbb2bfee8ce634aa00a8ea870c4c079f9680eabe2eb99c10a8bf9c2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
62
|
-
|
63
|
-
|
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
|
-
|
181
|
-
|
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)
|
data/lib/ohloh_scm/git/scm.rb
CHANGED
@@ -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
|
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)
|
data/lib/ohloh_scm/git/status.rb
CHANGED
@@ -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
|
data/lib/ohloh_scm/status.rb
CHANGED
data/lib/ohloh_scm/version.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module RepositoryHelper
|
4
|
-
%w[
|
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?
|
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.
|
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:
|
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 \
|