Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OTWO-4466 Set the branch_name as nil if empty string #47

Merged
1 commit merged into from Dec 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 10 additions & 5 deletions lib/ohloh_scm/adapters/hg_adapter.rb
@@ -1,9 +1,14 @@
module OhlohScm::Adapters
class HgAdapter < AbstractAdapter
def english_name
"Mercurial"
end
end
class HgAdapter < AbstractAdapter
def english_name
"Mercurial"
end

def branch_name=(branch_name)
branch_name = nil if branch_name.to_s.empty?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not branch_name.blank?, it can check both nil and empty values.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, blank? will throw NoMethodError: undefined method 'blank?' for nil:NilClass

super
end
end
end

require_relative 'hg/validation'
Expand Down
10 changes: 10 additions & 0 deletions test/unit/hg_commits_test.rb
Expand Up @@ -11,6 +11,16 @@ def test_commit_count
end
end

def test_commit_count_with_empty_branch
with_hg_repository('hg', '') do |hg|
assert_equal nil, hg.branch_name
assert_equal 5, hg.commit_count
assert_equal 3, hg.commit_count(:after => 'b14fa4692f949940bd1e28da6fb4617de2615484')
assert_equal 0, hg.commit_count(:after => '655f04cf6ad708ab58c7b941672dce09dd369a18')
end
end


def test_commit_tokens
with_hg_repository('hg') do |hg|
assert_equal ['01101d8ef3cea7da9ac6e9a226d645f4418f05c9',
Expand Down