diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-04-13 00:52:19 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-04-13 00:52:19 +0100 |
commit | 387c66c463d7658c8b120eb3852d562ac34ec8ba (patch) | |
tree | d762e5d0e773e5cb30f53c347c6c23e60ac50423 | |
parent | Ensure target category of move exists (diff) | |
download | gentoobrowse-api-387c66c463d7658c8b120eb3852d562ac34ec8ba.tar.bz2 gentoobrowse-api-387c66c463d7658c8b120eb3852d562ac34ec8ba.tar.xz gentoobrowse-api-387c66c463d7658c8b120eb3852d562ac34ec8ba.zip |
Factor writeChangesToFileList into its own function
-rw-r--r-- | gentoobrowse-api/service/maintenanceGitOperations.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/gentoobrowse-api/service/maintenanceGitOperations.cpp b/gentoobrowse-api/service/maintenanceGitOperations.cpp index 27ee672..9d9ae61 100644 --- a/gentoobrowse-api/service/maintenanceGitOperations.cpp +++ b/gentoobrowse-api/service/maintenanceGitOperations.cpp @@ -153,17 +153,19 @@ namespace Gentoo { return 0; } + static + void + writeChangesToFileList(DB::Connection * db, int64_t repoId, git_repository * repo, const git_oid & last, const git_oid & head); + void refreshRepository(DB::Connection * db, Ice::PropertiesPtr properties, int64_t repoId, const std::string & repoName, const std::string & path, const std::string & lastCommitId) { auto targetRef = properties->getProperty("GentooBrowseAPI.RefreshTarget." + repoName); auto repo = gitSafeGet(git_repository_open, git_repository_free, path.c_str()); auto lastCommitOid = gitSafeGet(git_oid_fromstr, lastCommitId.c_str()); - auto lastCommit = gitSafeGet(git_commit_lookup, git_commit_free, repo.get(), &lastCommitOid); auto headCommitOid = targetRef.empty() ? 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); @@ -171,9 +173,17 @@ namespace Gentoo { updateLastCommit->bindParamI(1, repoId); updateLastCommit->execute(); + writeChangesToFileList(db, repoId, repo.get(), lastCommitOid, headCommitOid); + } + + void + writeChangesToFileList(DB::Connection * db, int64_t repoId, git_repository * repo, const git_oid & lastCommitOid, const git_oid & headCommitOid) + { + auto lastCommit = gitSafeGet(git_commit_lookup, git_commit_free, repo, &lastCommitOid); + auto headCommit = gitSafeGet(git_commit_lookup, git_commit_free, repo, &headCommitOid); auto lastTree = gitSafeGet(git_commit_tree, git_tree_free, lastCommit.get()); auto headTree = gitSafeGet(git_commit_tree, git_tree_free, headCommit.get()); - auto diff = gitSafeGet(git_diff_tree_to_tree, git_diff_free, repo.get(), lastTree.get(), headTree.get(), nullptr); + auto diff = gitSafeGet(git_diff_tree_to_tree, git_diff_free, repo, lastTree.get(), headTree.get(), nullptr); auto ins = db->modify("INSERT INTO filelistraw(repoid, status, filename) VALUES(?, ?, ?)"); ins->bindParamI(0, repoId); gitSafe(git_diff_foreach, diff.get(), insertFileChange, nullptr, nullptr, nullptr, ins.get()); |