From 020555821575f8717b3aa36aebdb9012a86b9016 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 13 Mar 2023 17:03:17 +0100 Subject: GitRepo: Add proper error message for keep tag operation --- src/buildtool/file_system/git_repo.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/buildtool/file_system/git_repo.cpp') diff --git a/src/buildtool/file_system/git_repo.cpp b/src/buildtool/file_system/git_repo.cpp index 4c88e4a7..7e7a4d18 100644 --- a/src/buildtool/file_system/git_repo.cpp +++ b/src/buildtool/file_system/git_repo.cpp @@ -598,6 +598,7 @@ auto GitRepo::KeepTag(std::string const& commit, size_t max_attempts = kGitLockNumTries; // number of tries int err = 0; git_strarray tag_names{}; + std::string err_mess{}; while (max_attempts > 0) { --max_attempts; err = git_tag_create(&oid, @@ -610,6 +611,7 @@ auto GitRepo::KeepTag(std::string const& commit, if (err == 0) { return true; // success! } + err_mess = GitLastError(); // store last error message // check if tag hasn't already been added by another process if (git_tag_list_match(&tag_names, name.c_str(), repo_.get()) == 0 and @@ -623,9 +625,11 @@ auto GitRepo::KeepTag(std::string const& commit, std::this_thread::sleep_for( std::chrono::milliseconds(kGitLockWaitTime)); } - (*logger)(fmt::format("tag creation in git repository {} failed", - GetGitCAS()->git_path_.string()), - true /*fatal*/); + (*logger)( + fmt::format("tag creation in git repository {} failed with:\n{}", + GetGitCAS()->git_path_.string(), + err_mess), + true /*fatal*/); return false; } catch (std::exception const& ex) { Logger::Log(LogLevel::Error, "keep tag failed with:\n{}", ex.what()); -- cgit v1.2.3