summaryrefslogtreecommitdiff
path: root/src/buildtool/file_system/git_repo.hpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-08-13 18:01:50 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-08-26 11:36:35 +0200
commita312e71b59340f7b6d8dc5aac9202137ae81d02b (patch)
tree0601795d12487a2d8e4e87704f9592fd00e8bd08 /src/buildtool/file_system/git_repo.hpp
parentd7f6ca59d2e2713efe40c96e2c6522f6d86180d2 (diff)
downloadjustbuild-a312e71b59340f7b6d8dc5aac9202137ae81d02b.tar.gz
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.
Diffstat (limited to 'src/buildtool/file_system/git_repo.hpp')
-rw-r--r--src/buildtool/file_system/git_repo.hpp15
1 files changed, 9 insertions, 6 deletions
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<void(std::string const&, bool)>;
using anon_logger_ptr = std::shared_ptr<anon_logger_t>;
- /// \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<std::string>;
+ /// \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<std::string>;
/// \brief Create annotated tag for given commit.
/// Only possible with real repository and thus non-thread-safe.