diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2025-01-13 13:08:40 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2025-01-15 16:43:56 +0100 |
commit | 4309ecb7bf05197c5cd95419d9c5b7b63699c547 (patch) | |
tree | 3f21a31dfcc14628663b8807c34a58aded0822b7 /src/buildtool/file_system/git_repo.hpp | |
parent | dedfdcce70d7f7b503e30cd60a2475aca3ee9516 (diff) | |
download | justbuild-4309ecb7bf05197c5cd95419d9c5b7b63699c547.tar.gz |
Add to GitRepo common implementation of ImportToGit
Diffstat (limited to 'src/buildtool/file_system/git_repo.hpp')
-rw-r--r-- | src/buildtool/file_system/git_repo.hpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/buildtool/file_system/git_repo.hpp b/src/buildtool/file_system/git_repo.hpp index 798f9ffb..1e403fbe 100644 --- a/src/buildtool/file_system/git_repo.hpp +++ b/src/buildtool/file_system/git_repo.hpp @@ -18,6 +18,7 @@ #include <filesystem> #include <functional> #include <memory> +#include <mutex> #include <optional> #include <string> #include <unordered_map> @@ -315,6 +316,20 @@ class GitRepo { [[nodiscard]] auto GetConfigSnapshot() const noexcept -> std::shared_ptr<git_config>; + /// \brief Import source directory to target git repository + /// \param storage_config Storage where the source must be imported to + /// \param source_dir Directory to import + /// \param commit_message Message of the commit + /// \param tagging_lock Mutex to protect critical git operations + /// \return The tree id of the commited directory on success or an + /// unexpected error as string on failure. + [[nodiscard]] static auto ImportToGit( + StorageConfig const& storage_config, + std::filesystem::path const& source_dir, + std::string const& commit_message, + gsl::not_null<std::mutex*> const& tagging_lock) noexcept + -> expected<std::string, std::string>; + private: GitCASPtr git_cas_; // default to real repo, as that is non-thread-safe |