From a312e71b59340f7b6d8dc5aac9202137ae81d02b Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 13 Aug 2024 18:01:50 +0200 Subject: GitRepo: Change logic that creates commits to explicitly give directory In preparation for subsequent changes, specify the directory path containing the tree content to be committed explicitly. This change will allow eventually to be able to specify paths that are different from the root path of the repository in which the commit is created. This commit renames and refactors StageAndCommitAllAnnonymous to allow a directory path to be passed. The just-mr and serve service logic is updated such that current behaviour is otherwise unchanged. --- src/buildtool/file_system/git_repo.hpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/buildtool/file_system/git_repo.hpp') diff --git a/src/buildtool/file_system/git_repo.hpp b/src/buildtool/file_system/git_repo.hpp index 1e5ec839..31d9eb82 100644 --- a/src/buildtool/file_system/git_repo.hpp +++ b/src/buildtool/file_system/git_repo.hpp @@ -151,13 +151,16 @@ class GitRepo { using anon_logger_t = std::function; using anon_logger_ptr = std::shared_ptr; - /// \brief Stage all in current path and commit with given message. + /// \brief Create tree from entries at given directory and commit it with + /// given message. Currently, the caller must guarantee that given path is + /// a subdirectory of the repository root path. /// Only possible with real repository and thus non-thread-safe. - /// Returns the commit hash, or nullopt if failure. - /// It guarantees the logger is called exactly once with fatal if failure. - [[nodiscard]] auto StageAndCommitAllAnonymous( - std::string const& message, - anon_logger_ptr const& logger) noexcept -> std::optional; + /// \returns The commit hash, or nullopt if failure. It guarantees the + /// logger is called exactly once with fatal if failure. + [[nodiscard]] auto CommitDirectory(std::filesystem::path const& dir, + std::string const& message, + anon_logger_ptr const& logger) noexcept + -> std::optional; /// \brief Create annotated tag for given commit. /// Only possible with real repository and thus non-thread-safe. -- cgit v1.2.3