Move ensure_git_inited from utilities to git_common
This commit is contained in:
parent
be1e7a31bc
commit
4829551112
@ -17,6 +17,13 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
void ensure_git_inited() {
|
||||||
|
static std::once_flag git_init_flag;
|
||||||
|
std::call_once(git_init_flag, []() {
|
||||||
|
git_libgit2_init();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
static int submodule_trampoline(git_submodule* sm, const char* name, void* payload) {
|
static int submodule_trampoline(git_submodule* sm, const char* name, void* payload) {
|
||||||
// Cast payload back to the C++ lambda
|
// Cast payload back to the C++ lambda
|
||||||
auto* callback = static_cast<std::function<int(git_submodule*, const char*, void*)>*>(payload);
|
auto* callback = static_cast<std::function<int(git_submodule*, const char*, void*)>*>(payload);
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
void ensure_git_inited();
|
||||||
GitCommit get_commit_from_pkg_repo(const std::string& repo_name,
|
GitCommit get_commit_from_pkg_repo(const std::string& repo_name,
|
||||||
std::shared_ptr<Log> log);
|
std::shared_ptr<Log> log);
|
||||||
void clone_or_fetch(const fs::path &repo_dir,
|
void clone_or_fetch(const fs::path &repo_dir,
|
||||||
|
@ -270,13 +270,6 @@ std::pair<int, bool> get_version_from_codename(const std::string& codename) {
|
|||||||
return {version, is_last};
|
return {version, is_last};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ensure_git_inited() {
|
|
||||||
static std::once_flag git_init_flag;
|
|
||||||
std::call_once(git_init_flag, []() {
|
|
||||||
git_libgit2_init();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void run_task_every(std::stop_token _stop_token, int interval_minutes, std::function<void()> task) {
|
void run_task_every(std::stop_token _stop_token, int interval_minutes, std::function<void()> task) {
|
||||||
if (interval_minutes < 2) interval_minutes = 2;
|
if (interval_minutes < 2) interval_minutes = 2;
|
||||||
std::this_thread::sleep_for(std::chrono::minutes(interval_minutes / 2));
|
std::this_thread::sleep_for(std::chrono::minutes(interval_minutes / 2));
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
#include <semaphore>
|
#include <semaphore>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <git2.h>
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
@ -102,9 +101,6 @@ std::string generate_random_string(size_t length);
|
|||||||
// Get version from codename using distro-info
|
// Get version from codename using distro-info
|
||||||
std::pair<int, bool> get_version_from_codename(const std::string& codename);
|
std::pair<int, bool> get_version_from_codename(const std::string& codename);
|
||||||
|
|
||||||
// Git utilities
|
|
||||||
void ensure_git_inited();
|
|
||||||
|
|
||||||
void run_task_every(std::stop_token _stop_token, int interval_minutes, std::function<void()> task);
|
void run_task_every(std::stop_token _stop_token, int interval_minutes, std::function<void()> task);
|
||||||
|
|
||||||
// Logger functions
|
// Logger functions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user