summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-06-13 19:54:32 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2016-06-13 19:54:32 +0100
commitfee01ee2dcc209989dc365abb4c0518ccb8d5083 (patch)
tree26dcdda019dbc366aa884f0190dede89e3fd0766
parentcommitid can be a straight char(40), it won't vary (diff)
downloadgentoobrowse-api-fee01ee2dcc209989dc365abb4c0518ccb8d5083.tar.bz2
gentoobrowse-api-fee01ee2dcc209989dc365abb4c0518ccb8d5083.tar.xz
gentoobrowse-api-fee01ee2dcc209989dc365abb4c0518ccb8d5083.zip
Dedupe the change log file list
-rw-r--r--gentoobrowse-api/service/maintenanceChangeLogs.cpp3
-rw-r--r--gentoobrowse-api/unittests/testChangeLog.cpp2
2 files changed, 5 insertions, 0 deletions
diff --git a/gentoobrowse-api/service/maintenanceChangeLogs.cpp b/gentoobrowse-api/service/maintenanceChangeLogs.cpp
index 46ef3e2..027429e 100644
--- a/gentoobrowse-api/service/maintenanceChangeLogs.cpp
+++ b/gentoobrowse-api/service/maintenanceChangeLogs.cpp
@@ -104,6 +104,9 @@ namespace Gentoo {
// Compare trees
StringList fs;
git_diff_foreach(diff.get(), onFile, onBinaryFile, nullptr, nullptr, &fs);
+ // Remove duplicate mentions of files
+ std::sort(fs.begin(), fs.end());
+ fs.erase(std::unique(fs.begin(), fs.end()), fs.end());
// Insert commit into DB
cli->bindParamS(1, str);
diff --git a/gentoobrowse-api/unittests/testChangeLog.cpp b/gentoobrowse-api/unittests/testChangeLog.cpp
index 412b328..df01a7b 100644
--- a/gentoobrowse-api/unittests/testChangeLog.cpp
+++ b/gentoobrowse-api/unittests/testChangeLog.cpp
@@ -22,9 +22,11 @@ BOOST_AUTO_TEST_CASE( importChangeLogs )
insRepo->execute();
const int64_t expectedLogCount = 125;
+ const int64_t expectedFilesCount = 9;
m->refreshChangeLogs();
SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.changelog", int64_t, expectedLogCount);
+ SQL_REQUIRE_EQUAL("SELECT ARRAY_LENGTH(files, 1) FROM gentoobrowse.changelog WHERE commitid = 'f8e9b2f0044232213a6e0299a3f31752e8dd9d24'", int64_t, expectedFilesCount);
db->execute("COPY gentoobrowse.changelog TO '/tmp/changelog.tsv'");
}