diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-03-04 23:45:47 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-03-04 23:45:47 +0000 |
commit | a8eb886f3436dafd9907478da464fc989fcfb019 (patch) | |
tree | 144093662a6fbad71a6a40d3a303f437f93f6e1a | |
parent | Fix root dir paths for git import (diff) | |
download | gentoobrowse-api-a8eb886f3436dafd9907478da464fc989fcfb019.tar.bz2 gentoobrowse-api-a8eb886f3436dafd9907478da464fc989fcfb019.tar.xz gentoobrowse-api-a8eb886f3436dafd9907478da464fc989fcfb019.zip |
Update lastcommit when performing a git tree update
-rw-r--r-- | gentoobrowse-api/service/maintenanceGitOperations.cpp | 6 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/testMaintenance.cpp | 1 |
2 files changed, 7 insertions, 0 deletions
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 |