summaryrefslogtreecommitdiff
path: root/gentoobrowse-api/service/utils
diff options
context:
space:
mode:
Diffstat (limited to 'gentoobrowse-api/service/utils')
-rw-r--r--gentoobrowse-api/service/utils/dbUtils.cpp21
-rw-r--r--gentoobrowse-api/service/utils/dbUtils.h13
-rw-r--r--gentoobrowse-api/service/utils/ebuildCacheParser.cpp6
-rw-r--r--gentoobrowse-api/service/utils/ebuildCacheParser.h21
-rw-r--r--gentoobrowse-api/service/utils/entityWhereFilter.cpp13
-rw-r--r--gentoobrowse-api/service/utils/entityWhereFilter.h24
-rw-r--r--gentoobrowse-api/service/utils/git.cpp17
-rw-r--r--gentoobrowse-api/service/utils/git.h27
-rw-r--r--gentoobrowse-api/service/utils/splitEbuildProps.cpp13
-rw-r--r--gentoobrowse-api/service/utils/splitEbuildProps.h18
-rw-r--r--gentoobrowse-api/service/utils/xmlUtils.cpp6
-rw-r--r--gentoobrowse-api/service/utils/xmlUtils.h9
12 files changed, 82 insertions, 106 deletions
diff --git a/gentoobrowse-api/service/utils/dbUtils.cpp b/gentoobrowse-api/service/utils/dbUtils.cpp
index 3e70281..c281265 100644
--- a/gentoobrowse-api/service/utils/dbUtils.cpp
+++ b/gentoobrowse-api/service/utils/dbUtils.cpp
@@ -1,9 +1,9 @@
#include "dbUtils.h"
-#include <boost/lexical_cast.hpp>
+#include <atomic>
#include <boost/algorithm/string/join.hpp>
-#include <tablepatch.h>
+#include <boost/lexical_cast.hpp>
#include <buffer.h>
-#include <atomic>
+#include <tablepatch.h>
namespace Gentoo {
namespace Utils {
@@ -22,7 +22,8 @@ namespace Gentoo {
}
std::pair<std::string, DB::ModifyCommandPtr>
- namedTemp(DB::Connection * db, const std::string & tempTable, const std::map<std::string, const std::string> & cols)
+ namedTemp(DB::Connection * db, const std::string & tempTable,
+ const std::map<std::string, const std::string> & cols)
{
std::set<std::string> keys;
std::set<std::string> defs;
@@ -30,9 +31,8 @@ namespace Gentoo {
keys.insert(c.first);
defs.insert(c.first + " " + c.second);
}
- db->execute("CREATE TEMPORARY TABLE " + tempTable + "(" +
- boost::join(defs, ",") + ")");
- return { tempTable, tablePatchInserter(db, tempTable, keys) };
+ db->execute("CREATE TEMPORARY TABLE " + tempTable + "(" + boost::join(defs, ",") + ")");
+ return {tempTable, tablePatchInserter(db, tempTable, keys)};
}
void
@@ -49,12 +49,9 @@ namespace Gentoo {
DB::ModifyCommandPtr
tablePatchInserter(DB::Connection * dbc, const std::string & t, const std::set<std::string> & c)
{
- return dbc->modify(
- "INSERT INTO " + t +
- "(" + boost::algorithm::join(c, ", ") +
- ") VALUES(" + boost::algorithm::join(std::vector<std::string>(c.size(), "?"), ", ") + ")");
+ return dbc->modify("INSERT INTO " + t + "(" + boost::algorithm::join(c, ", ") + ") VALUES("
+ + boost::algorithm::join(std::vector<std::string>(c.size(), "?"), ", ") + ")");
}
}
}
}
-
diff --git a/gentoobrowse-api/service/utils/dbUtils.h b/gentoobrowse-api/service/utils/dbUtils.h
index cbb8292..cdd9c07 100644
--- a/gentoobrowse-api/service/utils/dbUtils.h
+++ b/gentoobrowse-api/service/utils/dbUtils.h
@@ -1,23 +1,24 @@
#ifndef GENTOOBROWSE_API_SERVICE_DBUTILS_H
#define GENTOOBROWSE_API_SERVICE_DBUTILS_H
-#include <command.h>
-#include <modifycommand.h>
-#include <connection.h>
#include <IceUtil/Exception.h>
#include <IceUtil/Optional.h>
+#include <command.h>
+#include <connection.h>
+#include <modifycommand.h>
namespace Gentoo {
namespace Utils {
namespace Database {
std::string emptyClone(DB::Connection *, const std::string &);
- std::pair<std::string, DB::ModifyCommandPtr> namedTemp(DB::Connection *, const std::string &, const std::map<std::string, const std::string> & cols);
+ std::pair<std::string, DB::ModifyCommandPtr> namedTemp(
+ DB::Connection *, const std::string &, const std::map<std::string, const std::string> & cols);
void drop(DB::Connection *, const std::string &);
DB::ModifyCommandPtr tablePatchInserter(DB::Connection *, const DB::TablePatch &);
- DB::ModifyCommandPtr tablePatchInserter(DB::Connection *, const std::string &, const std::set<std::string> &);
+ DB::ModifyCommandPtr tablePatchInserter(
+ DB::Connection *, const std::string &, const std::set<std::string> &);
}
}
}
#endif
-
diff --git a/gentoobrowse-api/service/utils/ebuildCacheParser.cpp b/gentoobrowse-api/service/utils/ebuildCacheParser.cpp
index bbe804e..cd50d1a 100644
--- a/gentoobrowse-api/service/utils/ebuildCacheParser.cpp
+++ b/gentoobrowse-api/service/utils/ebuildCacheParser.cpp
@@ -2,13 +2,12 @@
namespace Gentoo {
namespace Utils {
- EbuildCacheParser::EbuildCacheParser(const std::filesystem::path & p) :
- AdHoc::FileUtils::MemMap(p)
+ EbuildCacheParser::EbuildCacheParser(const std::filesystem::path & p) : AdHoc::FileUtils::MemMap(p)
{
auto chardata = sv();
for (auto eq = chardata.find('='); eq != std::string_view::npos; eq = chardata.find('=')) {
if (auto nl = chardata.find('\n', eq + 1); nl != std::string_view::npos) {
- kvs.insert({ chardata.substr(0, eq), chardata.substr(eq + 1, nl - eq - 1) });
+ kvs.insert({chardata.substr(0, eq), chardata.substr(eq + 1, nl - eq - 1)});
chardata.remove_prefix(nl + 1);
}
}
@@ -35,4 +34,3 @@ namespace Gentoo {
}
}
}
-
diff --git a/gentoobrowse-api/service/utils/ebuildCacheParser.h b/gentoobrowse-api/service/utils/ebuildCacheParser.h
index 6874d40..1573439 100644
--- a/gentoobrowse-api/service/utils/ebuildCacheParser.h
+++ b/gentoobrowse-api/service/utils/ebuildCacheParser.h
@@ -2,28 +2,27 @@
#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_EBUILDCACHEPARSER_H
#include <fileUtils.h>
-#include <map>
-#include <string_view>
-#include <optional>
#include <filesystem>
#include <glibmm/ustring.h>
+#include <map>
+#include <optional>
+#include <string_view>
namespace Gentoo {
namespace Utils {
class EbuildCacheParser : public AdHoc::FileUtils::MemMap {
- public:
- typedef std::map<std::string_view, const std::string_view> KVs;
+ public:
+ typedef std::map<std::string_view, const std::string_view> KVs;
- EbuildCacheParser(const std::filesystem::path & p);
+ EbuildCacheParser(const std::filesystem::path & p);
- std::optional<Glib::ustring> get(const std::string & key) const;
- std::optional<std::string_view> getRange(const std::string & key) const;
+ std::optional<Glib::ustring> get(const std::string & key) const;
+ std::optional<std::string_view> getRange(const std::string & key) const;
- private:
- KVs kvs;
+ private:
+ KVs kvs;
};
}
}
#endif
-
diff --git a/gentoobrowse-api/service/utils/entityWhereFilter.cpp b/gentoobrowse-api/service/utils/entityWhereFilter.cpp
index 2588edd..93a36aa 100644
--- a/gentoobrowse-api/service/utils/entityWhereFilter.cpp
+++ b/gentoobrowse-api/service/utils/entityWhereFilter.cpp
@@ -3,23 +3,17 @@
namespace Gentoo {
namespace Utils {
- template<typename T>
- EntityWhereFilter<T>::EntityWhereFilter(const std::string & en) :
- entityColName(en)
- {
- }
+ template<typename T> EntityWhereFilter<T>::EntityWhereFilter(const std::string & en) : entityColName(en) { }
template<typename T>
- EntityWhereFilter<T>::EntityWhereFilter(const std::string & en, const T & e) :
- entityColName(en)
+ EntityWhereFilter<T>::EntityWhereFilter(const std::string & en, const T & e) : entityColName(en)
{
entityIds.insert(e);
}
template<typename T>
EntityWhereFilter<T>::EntityWhereFilter(const std::string & en, const EntityIds & e) :
- entityIds(e),
- entityColName(en)
+ entityIds(e), entityColName(en)
{
}
@@ -61,4 +55,3 @@ namespace Gentoo {
template class EntityWhereFilter<std::string>;
}
}
-
diff --git a/gentoobrowse-api/service/utils/entityWhereFilter.h b/gentoobrowse-api/service/utils/entityWhereFilter.h
index 94e286d..805e033 100644
--- a/gentoobrowse-api/service/utils/entityWhereFilter.h
+++ b/gentoobrowse-api/service/utils/entityWhereFilter.h
@@ -1,28 +1,26 @@
#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_ENTITYWHEREFILTER_H
#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_ENTITYWHEREFILTER_H
-#include <sqlWriter.h>
#include <set>
+#include <sqlWriter.h>
namespace Gentoo {
namespace Utils {
- template<typename T>
- class EntityWhereFilter : public DB::SqlWriter {
- public:
- typedef std::set<T> EntityIds;
+ template<typename T> class EntityWhereFilter : public DB::SqlWriter {
+ public:
+ typedef std::set<T> EntityIds;
- EntityWhereFilter(const std::string & en);
- EntityWhereFilter(const std::string & en, const T & e);
- EntityWhereFilter(const std::string & en, const EntityIds & e);
+ EntityWhereFilter(const std::string & en);
+ EntityWhereFilter(const std::string & en, const T & e);
+ EntityWhereFilter(const std::string & en, const EntityIds & e);
- void writeSql(AdHoc::Buffer & sql) override;
- void bindParams(DB::Command * c, unsigned int & offset) override;
+ void writeSql(AdHoc::Buffer & sql) override;
+ void bindParams(DB::Command * c, unsigned int & offset) override;
- EntityIds entityIds;
- const std::string entityColName;
+ EntityIds entityIds;
+ const std::string entityColName;
};
}
}
#endif
-
diff --git a/gentoobrowse-api/service/utils/git.cpp b/gentoobrowse-api/service/utils/git.cpp
index 450bfec..1d7d9a8 100644
--- a/gentoobrowse-api/service/utils/git.cpp
+++ b/gentoobrowse-api/service/utils/git.cpp
@@ -1,8 +1,8 @@
#include "git.h"
-#include <maintenance.h>
-#include <execinfo.h>
#include <compileTimeFormatter.h>
+#include <execinfo.h>
#include <logger.h>
+#include <maintenance.h>
namespace Gentoo {
namespace Utils {
@@ -41,8 +41,8 @@ namespace Gentoo {
auto localBranch = gitSafeGet(git_repository_head, git_reference_free, repo);
auto localBranchName = gitSafeGet(git_branch_name, localBranch.get());
auto refspec = RefSpec::get(localBranchName, git_remote_name(remote), remoteBranchName);
- char * s[] = { &refspec.front() };
- git_strarray refs = { s, 1 };
+ char * s[] = {&refspec.front()};
+ git_strarray refs = {s, 1};
gitSafe(git_remote_fetch, remote, &refs, &opts, nullptr);
return gitSafeGet(git_annotated_commit_from_revspec, git_annotated_commit_free, repo, "FETCH_HEAD");
}
@@ -54,7 +54,7 @@ namespace Gentoo {
{
auto log = LOGMANAGER()->getLogger(__FUNCTION__);
// Test fast-forward is possible
- const git_annotated_commit * heads[] = { fetch_head };
+ const git_annotated_commit * heads[] = {fetch_head};
git_merge_analysis_t analysis = GIT_MERGE_ANALYSIS_NONE;
git_merge_preference_t preference = GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY;
gitSafe(git_merge_analysis, &analysis, &preference, repo, heads, 1);
@@ -69,8 +69,10 @@ namespace Gentoo {
// Perform fast-forward
auto fetch_head_id = *git_annotated_commit_id(fetch_head);
- auto fetch_head_object = gitSafeGet(git_object_lookup, git_object_free, repo, &fetch_head_id, GIT_OBJ_ANY);
- log->messagectf<FastForward>(IceTray::Logging::LogLevel::INFO, *git_reference_target(head.get()), fetch_head_id);
+ auto fetch_head_object
+ = gitSafeGet(git_object_lookup, git_object_free, repo, &fetch_head_id, GIT_OBJ_ANY);
+ log->messagectf<FastForward>(
+ IceTray::Logging::LogLevel::INFO, *git_reference_target(head.get()), fetch_head_id);
gitSafeGet(git_reference_set_target, git_reference_free, head.get(), &fetch_head_id, "fast-forward");
// Checkout new head
@@ -108,4 +110,3 @@ namespace std {
return s;
}
}
-
diff --git a/gentoobrowse-api/service/utils/git.h b/gentoobrowse-api/service/utils/git.h
index 20e8755..7e2e66a 100644
--- a/gentoobrowse-api/service/utils/git.h
+++ b/gentoobrowse-api/service/utils/git.h
@@ -1,8 +1,8 @@
#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_GIT_H
#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_GIT_H
-#include <memory>
#include <git2.h>
+#include <memory>
#include <ostream>
namespace Gentoo {
@@ -10,30 +10,29 @@ namespace Gentoo {
namespace Git {
void throwError(void * const func, int err);
- template<typename ... P, typename ... A>
+ template<typename... P, typename... A>
void
- gitSafe(int (*func)(P...), A ... p)
+ gitSafe(int (*func)(P...), A... p)
{
if (int _giterror = func(p...) < 0) {
throwError((void * const)func, _giterror);
}
}
- template<typename T>
- using GitTPtr = std::unique_ptr<T, void(*)(T*)>;
+ template<typename T> using GitTPtr = std::unique_ptr<T, void (*)(T *)>;
- template<typename R, typename ... P, typename ... A>
+ template<typename R, typename... P, typename... A>
GitTPtr<R>
- gitSafeGet(int(*get)(R**, P...), void(*release)(R*), A ... p)
+ gitSafeGet(int (*get)(R **, P...), void (*release)(R *), A... p)
{
R * r = nullptr;
gitSafe(get, &r, p...);
return GitTPtr<R>(r, release);
}
- template<typename R, typename ... P, typename ... A>
+ template<typename R, typename... P, typename... A>
R
- gitSafeGet(int(*get)(R*, P...), A ... p)
+ gitSafeGet(int (*get)(R *, P...), A... p)
{
R r;
gitSafe(get, &r, p...);
@@ -43,14 +42,11 @@ namespace Gentoo {
std::string operator*(const git_oid &);
using GitAnnotatedCommitPtr = GitTPtr<git_annotated_commit>;
- GitAnnotatedCommitPtr
- gitFetch(git_repository * repo, git_remote * remote, const char * branch);
+ GitAnnotatedCommitPtr gitFetch(git_repository * repo, git_remote * remote, const char * branch);
- git_oid
- gitFastForward(git_repository * repo, const git_annotated_commit * fetch_head);
+ git_oid gitFastForward(git_repository * repo, const git_annotated_commit * fetch_head);
- void
- updateRepository(const std::string & path, const std::string & upstream, const std::string & branch);
+ void updateRepository(const std::string & path, const std::string & upstream, const std::string & branch);
}
}
}
@@ -60,4 +56,3 @@ namespace std {
}
#endif
-
diff --git a/gentoobrowse-api/service/utils/splitEbuildProps.cpp b/gentoobrowse-api/service/utils/splitEbuildProps.cpp
index ce052ab..3d6b6e8 100644
--- a/gentoobrowse-api/service/utils/splitEbuildProps.cpp
+++ b/gentoobrowse-api/service/utils/splitEbuildProps.cpp
@@ -1,21 +1,21 @@
#include "splitEbuildProps.h"
-#include <command.h>
#include "dbUtils.h"
+#include <command.h>
namespace Gentoo {
namespace Utils {
- SplitEbuildProps::SplitEbuildProps(const std::string & ce, int e, const std::string & cp, const std::optional<Glib::ustring> & p) :
+ SplitEbuildProps::SplitEbuildProps(
+ const std::string & ce, int e, const std::string & cp, const std::optional<Glib::ustring> & p) :
entityId(e),
- colEntityName(ce),
- colPropName(cp),
- props(p)
+ colEntityName(ce), colPropName(cp), props(p)
{
}
void
SplitEbuildProps::writeSql(AdHoc::Buffer & sql)
{
- sql.appendbf("(SELECT DISTINCT ?::int %s, trim(regexp_split_to_table(?, '\\s+'), '+') %s)", colEntityName, colPropName);
+ sql.appendbf("(SELECT DISTINCT ?::int %s, trim(regexp_split_to_table(?, '\\s+'), '+') %s)", colEntityName,
+ colPropName);
}
void
@@ -26,4 +26,3 @@ namespace Gentoo {
}
}
}
-
diff --git a/gentoobrowse-api/service/utils/splitEbuildProps.h b/gentoobrowse-api/service/utils/splitEbuildProps.h
index c6ed14f..00ce910 100644
--- a/gentoobrowse-api/service/utils/splitEbuildProps.h
+++ b/gentoobrowse-api/service/utils/splitEbuildProps.h
@@ -1,25 +1,25 @@
#ifndef GENTOOBROWSE_API_SERVICE_MAINTENANCE_SPLITEBUILDPROPS_H
#define GENTOOBROWSE_API_SERVICE_MAINTENANCE_SPLITEBUILDPROPS_H
-#include <sqlWriter.h>
#include <glibmm/ustring.h>
#include <optional>
+#include <sqlWriter.h>
namespace Gentoo {
namespace Utils {
class SplitEbuildProps : public DB::SqlWriter {
- public:
- SplitEbuildProps(const std::string & ce, int e, const std::string & cp, const std::optional<Glib::ustring> & p);
+ public:
+ SplitEbuildProps(
+ const std::string & ce, int e, const std::string & cp, const std::optional<Glib::ustring> & p);
- void writeSql(AdHoc::Buffer & sql) override;
- void bindParams(DB::Command * c, unsigned int & offset) override;
+ void writeSql(AdHoc::Buffer & sql) override;
+ void bindParams(DB::Command * c, unsigned int & offset) override;
- const int entityId;
- const std::string colEntityName, colPropName;
- const std::optional<Glib::ustring> props;
+ const int entityId;
+ const std::string colEntityName, colPropName;
+ const std::optional<Glib::ustring> props;
};
}
}
#endif
-
diff --git a/gentoobrowse-api/service/utils/xmlUtils.cpp b/gentoobrowse-api/service/utils/xmlUtils.cpp
index f938efa..1ddc16e 100644
--- a/gentoobrowse-api/service/utils/xmlUtils.cpp
+++ b/gentoobrowse-api/service/utils/xmlUtils.cpp
@@ -2,10 +2,7 @@
namespace Gentoo {
namespace Utils {
- XmlDoc::XmlDoc(const std::filesystem::path & path) :
- xmlpp::DomParser(path)
- {
- }
+ XmlDoc::XmlDoc(const std::filesystem::path & path) : xmlpp::DomParser(path) { }
std::optional<Glib::ustring>
XmlDoc::getXPathValue(const Glib::ustring & xp)
@@ -23,4 +20,3 @@ namespace Gentoo {
}
}
}
-
diff --git a/gentoobrowse-api/service/utils/xmlUtils.h b/gentoobrowse-api/service/utils/xmlUtils.h
index 3e71f1d..82584cc 100644
--- a/gentoobrowse-api/service/utils/xmlUtils.h
+++ b/gentoobrowse-api/service/utils/xmlUtils.h
@@ -1,20 +1,19 @@
#ifndef GENTOOBROWSE_API_SERVICE_XMLUTILS_H
#define GENTOOBROWSE_API_SERVICE_XMLUTILS_H
-#include <libxml++/parsers/domparser.h>
#include <filesystem>
+#include <libxml++/parsers/domparser.h>
#include <optional>
namespace Gentoo {
namespace Utils {
class XmlDoc : public xmlpp::DomParser {
- public:
- XmlDoc(const std::filesystem::path &);
+ public:
+ XmlDoc(const std::filesystem::path &);
- std::optional<Glib::ustring> getXPathValue(const Glib::ustring &);
+ std::optional<Glib::ustring> getXPathValue(const Glib::ustring &);
};
}
}
#endif
-