Skip to content

Commit a3c48ba

Browse files
committed
exist? must rely on raising exceptions like in v2
The exist? method in version 2 relied upon purposefully raising exceptions to indicate that a repository is missing. In v3 we tried to replace this with a check for scm_dir(.git, .hg etc) instead. However we now realize that exist? needs also to work for remote urls. So we are reverting back to the ohloh_scm v2 logic: https://github.com/blackducksoftware/ohloh_scm/blob/v2.5.1/lib/ohloh_scm/adapters/git/misc.rb#L7
1 parent 2cc336a commit a3c48ba

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

lib/ohloh_scm/status.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ def initialize(core)
1212
end
1313

1414
def exist?
15-
return unless scm_dir_exist?
16-
1715
!activity.head_token.to_s.empty?
16+
rescue RuntimeError
17+
logger.debug { $ERROR_INFO.inspect }
18+
false
1819
end
1920

2021
def scm_dir_exist?

spec/ohloh_scm/bzr/scm_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
with_bzr_repository('bzr') do |src|
88
tmpdir do |dest_dir|
99
core = OhlohScm::Factory.get_core(scm_type: :bzr, url: dest_dir)
10-
refute core.status.exist?
10+
refute core.status.scm_dir_exist?
1111

1212
core.scm.pull(src.scm, TestCallback.new)
13+
assert core.status.scm_dir_exist?
1314
assert core.status.exist?
1415
end
1516
end

spec/ohloh_scm/git/scm_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
with_git_repository('git') do |src_core|
66
tmpdir do |dest_dir|
77
core = OhlohScm::Factory.get_core(scm_type: :git, url: dest_dir)
8-
refute core.status.exist?
8+
refute core.status.scm_dir_exist?
99

1010
core.scm.pull(src_core.scm, TestCallback.new)
11+
assert core.status.scm_dir_exist?
1112
assert core.status.exist?
1213
end
1314
end
@@ -19,7 +20,7 @@
1920
with_git_repository('git_with_multiple_branch', 'test') do |src_core|
2021
tmpdir do |dest_dir|
2122
core = OhlohScm::Factory.get_core(scm_type: :git, url: dest_dir, branch_name: 'test')
22-
refute core.status.exist?
23+
refute core.status.scm_dir_exist?
2324
core.scm.pull(src_core.scm, TestCallback.new)
2425

2526
remote_master_branch_sha = `cd #{dest_dir} && git rev-parse origin/master`
@@ -36,8 +37,9 @@
3637
with_cvs_repository('cvs', 'simple') do |src_core|
3738
tmpdir do |dest_dir|
3839
core = OhlohScm::Factory.get_core(scm_type: :git, url: dest_dir)
39-
refute core.status.exist?
40+
refute core.status.scm_dir_exist?
4041
core.scm.pull(src_core.scm, TestCallback.new)
42+
assert core.status.scm_dir_exist?
4143
assert core.status.exist?
4244

4345
dest_commits = core.activity.commits

0 commit comments

Comments
 (0)