From 88a1e3a40f0898457aae701f4dba9715dd3ae48d Mon Sep 17 00:00:00 2001 From: Daniel Rubio Date: Thu, 2 Feb 2017 16:44:33 +0000 Subject: [PATCH 01/11] Add test case for remove_dupes with SQL_ASCII test case --- test/unit/svn_commits_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unit/svn_commits_test.rb b/test/unit/svn_commits_test.rb index c6758594..2fbbd80c 100644 --- a/test/unit/svn_commits_test.rb +++ b/test/unit/svn_commits_test.rb @@ -106,6 +106,16 @@ def test_remove_dupes_add_replace assert_equal 'A', c.diffs.first.action end + def test_remove_dupes_with_sql_acii_encoding + #Note: If there are two files that are identical except for the encoding, ohloh_scm should only keep one. + svn = SvnAdapter.new + c = OhlohScm::Commit.new(:diffs => [OhlohScm::Diff.new(:action => "A", :path => "foo"), + OhlohScm::Diff.new(:action => "A", :path => "foo".force_encoding(Encoding::US-ASCII) ]) + svn.remove_dupes(c) + assert_equal 1, c.diffs.size + assert_equal 'A', c.diffs.first.action + end + # Had so many bugs around this case that a test was required def test_deepen_commit_with_nil_diffs with_svn_repository('svn') do |svn| From d234fac73a8f838910d20f9d81164bf0cab91082 Mon Sep 17 00:00:00 2001 From: Daniel Rubio Date: Thu, 2 Feb 2017 16:58:36 +0000 Subject: [PATCH 02/11] Correct syntax error --- test/unit/svn_commits_test.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/unit/svn_commits_test.rb b/test/unit/svn_commits_test.rb index 2fbbd80c..44ff392a 100644 --- a/test/unit/svn_commits_test.rb +++ b/test/unit/svn_commits_test.rb @@ -109,8 +109,9 @@ def test_remove_dupes_add_replace def test_remove_dupes_with_sql_acii_encoding #Note: If there are two files that are identical except for the encoding, ohloh_scm should only keep one. svn = SvnAdapter.new - c = OhlohScm::Commit.new(:diffs => [OhlohScm::Diff.new(:action => "A", :path => "foo"), - OhlohScm::Diff.new(:action => "A", :path => "foo".force_encoding(Encoding::US-ASCII) ]) + c = OhlohScm::Commit.new(:diffs => [ OhlohScm::Diff.new(:action => "R", :path => "foo"), + OhlohScm::Diff.new(:action => "A", :path => "foo") ]) + svn.remove_dupes(c) assert_equal 1, c.diffs.size assert_equal 'A', c.diffs.first.action From 296165b6835db283f7f374a481865f967e1941ca Mon Sep 17 00:00:00 2001 From: Daniel Rubio Date: Thu, 2 Feb 2017 17:03:14 +0000 Subject: [PATCH 03/11] Fix test case so it will deliberately break --- test/unit/svn_commits_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/svn_commits_test.rb b/test/unit/svn_commits_test.rb index 44ff392a..21b089c9 100644 --- a/test/unit/svn_commits_test.rb +++ b/test/unit/svn_commits_test.rb @@ -109,7 +109,7 @@ def test_remove_dupes_add_replace def test_remove_dupes_with_sql_acii_encoding #Note: If there are two files that are identical except for the encoding, ohloh_scm should only keep one. svn = SvnAdapter.new - c = OhlohScm::Commit.new(:diffs => [ OhlohScm::Diff.new(:action => "R", :path => "foo"), + c = OhlohScm::Commit.new(:diffs => [ OhlohScm::Diff.new(:action => "A", :path => "foo"), OhlohScm::Diff.new(:action => "A", :path => "foo") ]) svn.remove_dupes(c) From 5e0a9d7eae64183c5f5a216113d46a6633684442 Mon Sep 17 00:00:00 2001 From: Daniel Rubio Date: Thu, 2 Feb 2017 17:12:00 +0000 Subject: [PATCH 04/11] Add ascii encoding to test case --- test/unit/svn_commits_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/svn_commits_test.rb b/test/unit/svn_commits_test.rb index 21b089c9..9026d7a0 100644 --- a/test/unit/svn_commits_test.rb +++ b/test/unit/svn_commits_test.rb @@ -110,7 +110,7 @@ def test_remove_dupes_with_sql_acii_encoding #Note: If there are two files that are identical except for the encoding, ohloh_scm should only keep one. svn = SvnAdapter.new c = OhlohScm::Commit.new(:diffs => [ OhlohScm::Diff.new(:action => "A", :path => "foo"), - OhlohScm::Diff.new(:action => "A", :path => "foo") ]) + OhlohScm::Diff.new(:action => "A", :path => "foo".force_encoding('ASCII') ]) svn.remove_dupes(c) assert_equal 1, c.diffs.size From 739ba7c2e3dd89ed57af468fa2eeeee3fe233d63 Mon Sep 17 00:00:00 2001 From: Daniel Rubio Date: Thu, 2 Feb 2017 17:19:16 +0000 Subject: [PATCH 05/11] Correct syntax error --- test/unit/svn_commits_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/svn_commits_test.rb b/test/unit/svn_commits_test.rb index 9026d7a0..95789d7a 100644 --- a/test/unit/svn_commits_test.rb +++ b/test/unit/svn_commits_test.rb @@ -110,7 +110,7 @@ def test_remove_dupes_with_sql_acii_encoding #Note: If there are two files that are identical except for the encoding, ohloh_scm should only keep one. svn = SvnAdapter.new c = OhlohScm::Commit.new(:diffs => [ OhlohScm::Diff.new(:action => "A", :path => "foo"), - OhlohScm::Diff.new(:action => "A", :path => "foo".force_encoding('ASCII') ]) + OhlohScm::Diff.new(:action => "A", :path => "foo".force_encoding('ASCII')) ]) svn.remove_dupes(c) assert_equal 1, c.diffs.size From f61da9376b3399adbed6ee669a5d3a5158575574 Mon Sep 17 00:00:00 2001 From: Daniel Rubio Date: Thu, 2 Feb 2017 17:24:31 +0000 Subject: [PATCH 06/11] Add test fix --- lib/ohloh_scm/adapters/svn/commits.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ohloh_scm/adapters/svn/commits.rb b/lib/ohloh_scm/adapters/svn/commits.rb index 2b08f58e..1ce64079 100644 --- a/lib/ohloh_scm/adapters/svn/commits.rb +++ b/lib/ohloh_scm/adapters/svn/commits.rb @@ -186,7 +186,7 @@ def recurse_files(path=nil, revision=final_token || 'HEAD') files = [] stdout.each_line do |s| - s.chomp! + s.chomp!.force_encoding('UTF-8') files << s if s.length > 0 and s !~ /CVSROOT\// and s[-1..-1] != '/' end files.sort From 2e969972701eb8ebe088576fa8cda84280a46d8f Mon Sep 17 00:00:00 2001 From: Daniel Rubio Date: Thu, 2 Feb 2017 17:52:19 +0000 Subject: [PATCH 07/11] Add actual data for test --- test/unit/svn_commits_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/svn_commits_test.rb b/test/unit/svn_commits_test.rb index 95789d7a..586bf0c0 100644 --- a/test/unit/svn_commits_test.rb +++ b/test/unit/svn_commits_test.rb @@ -109,8 +109,8 @@ def test_remove_dupes_add_replace def test_remove_dupes_with_sql_acii_encoding #Note: If there are two files that are identical except for the encoding, ohloh_scm should only keep one. svn = SvnAdapter.new - c = OhlohScm::Commit.new(:diffs => [ OhlohScm::Diff.new(:action => "A", :path => "foo"), - OhlohScm::Diff.new(:action => "A", :path => "foo".force_encoding('ASCII')) ]) + c = OhlohScm::Commit.new(:diffs => [ OhlohScm::Diff.new(:action => "A", :path => "/FritzBoxDial/FritzBoxDial/formWählbox.vb"), + OhlohScm::Diff.new(:action => "A", :path => "/FritzBoxDial/FritzBoxDial/formW\xC3\xA4hlbox.vb" ]) svn.remove_dupes(c) assert_equal 1, c.diffs.size From 32af840a87531b3a5271fd066d4128f0a79577af Mon Sep 17 00:00:00 2001 From: Daniel Rubio Date: Thu, 2 Feb 2017 18:01:03 +0000 Subject: [PATCH 08/11] Fix syntax error --- test/unit/svn_commits_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/svn_commits_test.rb b/test/unit/svn_commits_test.rb index 586bf0c0..6e31e6db 100644 --- a/test/unit/svn_commits_test.rb +++ b/test/unit/svn_commits_test.rb @@ -110,7 +110,7 @@ def test_remove_dupes_with_sql_acii_encoding #Note: If there are two files that are identical except for the encoding, ohloh_scm should only keep one. svn = SvnAdapter.new c = OhlohScm::Commit.new(:diffs => [ OhlohScm::Diff.new(:action => "A", :path => "/FritzBoxDial/FritzBoxDial/formWählbox.vb"), - OhlohScm::Diff.new(:action => "A", :path => "/FritzBoxDial/FritzBoxDial/formW\xC3\xA4hlbox.vb" ]) + OhlohScm::Diff.new(:action => "A", :path => "/FritzBoxDial/FritzBoxDial/formW\xC3\xA4hlbox.vb") ]) svn.remove_dupes(c) assert_equal 1, c.diffs.size From 6066f37c13244c5c434850e4df71b257f7693079 Mon Sep 17 00:00:00 2001 From: Daniel Rubio Date: Thu, 2 Feb 2017 18:24:52 +0000 Subject: [PATCH 09/11] Add force encoding of ascii take 2 --- test/unit/svn_commits_test.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/unit/svn_commits_test.rb b/test/unit/svn_commits_test.rb index 6e31e6db..8c5aaee2 100644 --- a/test/unit/svn_commits_test.rb +++ b/test/unit/svn_commits_test.rb @@ -109,10 +109,12 @@ def test_remove_dupes_add_replace def test_remove_dupes_with_sql_acii_encoding #Note: If there are two files that are identical except for the encoding, ohloh_scm should only keep one. svn = SvnAdapter.new - c = OhlohScm::Commit.new(:diffs => [ OhlohScm::Diff.new(:action => "A", :path => "/FritzBoxDial/FritzBoxDial/formWählbox.vb"), - OhlohScm::Diff.new(:action => "A", :path => "/FritzBoxDial/FritzBoxDial/formW\xC3\xA4hlbox.vb") ]) - + diff_1 = OhlohScm::Diff.new(:action => "A", :path => "/FritzBoxDial/FritzBoxDial/formWählbox.vb") + diff_2 = OhlohScm::Diff.new(:action => "A", :path => "/FritzBoxDial/FritzBoxDial/formW\xC3\xA4hlbox.vb".force_encoding('ASCII')) + c = OhlohScm::Commit.new(:diffs => [diff_1 ,diff_2]) + svn.remove_dupes(c) + puts c.diffs.count assert_equal 1, c.diffs.size assert_equal 'A', c.diffs.first.action end From 34f17294f3931f0bd29e1a384238ad81e60a82ea Mon Sep 17 00:00:00 2001 From: Daniel Rubio Date: Thu, 2 Feb 2017 18:32:20 +0000 Subject: [PATCH 10/11] testing to see if tests pass now --- test/unit/svn_commits_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/svn_commits_test.rb b/test/unit/svn_commits_test.rb index 8c5aaee2..62ee534b 100644 --- a/test/unit/svn_commits_test.rb +++ b/test/unit/svn_commits_test.rb @@ -109,7 +109,7 @@ def test_remove_dupes_add_replace def test_remove_dupes_with_sql_acii_encoding #Note: If there are two files that are identical except for the encoding, ohloh_scm should only keep one. svn = SvnAdapter.new - diff_1 = OhlohScm::Diff.new(:action => "A", :path => "/FritzBoxDial/FritzBoxDial/formWählbox.vb") + diff_1 = OhlohScm::Diff.new(:action => "M", :path => "/FritzBoxDial/FritzBoxDial/formWählbox.vb") diff_2 = OhlohScm::Diff.new(:action => "A", :path => "/FritzBoxDial/FritzBoxDial/formW\xC3\xA4hlbox.vb".force_encoding('ASCII')) c = OhlohScm::Commit.new(:diffs => [diff_1 ,diff_2]) From 79ab4d784979fac5e6bf65c9ee17a19a6ab32190 Mon Sep 17 00:00:00 2001 From: Daniel Rubio Date: Thu, 2 Feb 2017 18:38:55 +0000 Subject: [PATCH 11/11] Is this build even working at all --- test/unit/svn_commits_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/svn_commits_test.rb b/test/unit/svn_commits_test.rb index 62ee534b..6ca727ac 100644 --- a/test/unit/svn_commits_test.rb +++ b/test/unit/svn_commits_test.rb @@ -110,7 +110,7 @@ def test_remove_dupes_with_sql_acii_encoding #Note: If there are two files that are identical except for the encoding, ohloh_scm should only keep one. svn = SvnAdapter.new diff_1 = OhlohScm::Diff.new(:action => "M", :path => "/FritzBoxDial/FritzBoxDial/formWählbox.vb") - diff_2 = OhlohScm::Diff.new(:action => "A", :path => "/FritzBoxDial/FritzBoxDial/formW\xC3\xA4hlbox.vb".force_encoding('ASCII')) + diff_2 = OhlohScm::Diff.new(:action => "A", :path => "/FritzBoxDial/FritzBoxDial/formWählbox.vb") c = OhlohScm::Commit.new(:diffs => [diff_1 ,diff_2]) svn.remove_dupes(c)