summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gentoobrowse-api/service/maintenanceGitOperations.cpp16
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());