From 4474205aef6399f1789bbcb857e2096c9de3886a Mon Sep 17 00:00:00 2001 From: Priya Rani Date: Tue, 27 Dec 2016 16:10:00 +0530 Subject: [PATCH] OTWO-4466 Set the branch_name as nil if empty string --- lib/ohloh_scm/adapters/hg_adapter.rb | 15 ++++++++++----- test/unit/hg_commits_test.rb | 10 ++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/ohloh_scm/adapters/hg_adapter.rb b/lib/ohloh_scm/adapters/hg_adapter.rb index 427668b1..eab19467 100644 --- a/lib/ohloh_scm/adapters/hg_adapter.rb +++ b/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? + super + end + end end require_relative 'hg/validation' diff --git a/test/unit/hg_commits_test.rb b/test/unit/hg_commits_test.rb index 9c1eb29b..f2b09b6f 100644 --- a/test/unit/hg_commits_test.rb +++ b/test/unit/hg_commits_test.rb @@ -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',