From a8eb886f3436dafd9907478da464fc989fcfb019 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 4 Mar 2017 23:45:47 +0000 Subject: Update lastcommit when performing a git tree update --- gentoobrowse-api/service/maintenanceGitOperations.cpp | 6 ++++++ gentoobrowse-api/unittests/testMaintenance.cpp | 1 + 2 files changed, 7 insertions(+) diff --git a/gentoobrowse-api/service/maintenanceGitOperations.cpp b/gentoobrowse-api/service/maintenanceGitOperations.cpp index c867c50..583968c 100644 --- a/gentoobrowse-api/service/maintenanceGitOperations.cpp +++ b/gentoobrowse-api/service/maintenanceGitOperations.cpp @@ -167,6 +167,12 @@ namespace Gentoo { gitSafeGet(git_reference_name_to_id, repo.get(), "HEAD") : gitSafeGet(git_oid_fromstr, targetRef.c_str()); auto headCommit = gitSafeGet(git_commit_lookup, git_commit_free, repo.get(), &headCommitOid); + auto updateLastCommit = db->modify("UPDATE gentoobrowse.repos SET lastCommit = ? WHERE repoId = ?"); + char buf[41]; + git_oid_tostr(buf, sizeof(buf), &headCommitOid); + updateLastCommit->bindParamS(0, buf); + updateLastCommit->bindParamI(1, repoId); + updateLastCommit->execute(); auto lastTree = gitSafeGet(git_commit_tree, git_tree_free, lastCommit.get()); auto headTree = gitSafeGet(git_commit_tree, git_tree_free, headCommit.get()); diff --git a/gentoobrowse-api/unittests/testMaintenance.cpp b/gentoobrowse-api/unittests/testMaintenance.cpp index dd5d5ad..26272d1 100644 --- a/gentoobrowse-api/unittests/testMaintenance.cpp +++ b/gentoobrowse-api/unittests/testMaintenance.cpp @@ -195,6 +195,7 @@ BOOST_AUTO_TEST_CASE( testRefreshGitRepository ) // Import it m->refreshPackageTreeGit(); + SQL_REQUIRE_EQUAL(R"SQL(SELECT lastCommit FROM gentoobrowse.repos)SQL", std::string, "40539afe6705aee26a55bb861f5e892ae7240057"); BOOST_TEST_CONTEXT("libkgapi was moved correctly") { BOOST_TEST_CONTEXT("from net-libs to kde-apps") { SQL_REQUIRE_EQUAL(R"SQL(SELECT COUNT(*) FROM gentoobrowse.categories c, gentoobrowse.packages p -- cgit v1.2.3