From: Michael Friedrich Date: Mon, 27 Oct 2014 10:02:14 +0000 (+0100) Subject: Cli: Delete change file on repository commit X-Git-Tag: v2.2.0~250 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d86ae67507be3a0a4865ddeb7b809c00cf1ec03;p=icinga2 Cli: Delete change file on repository commit refs #7255 --- diff --git a/lib/cli/repositoryutility.cpp b/lib/cli/repositoryutility.cpp index 3b9558c46..169932dd3 100644 --- a/lib/cli/repositoryutility.cpp +++ b/lib/cli/repositoryutility.cpp @@ -141,7 +141,7 @@ bool RepositoryUtility::RemoveObject(const String& name, const String& type, con bool RepositoryUtility::CommitChangeLog(void) { - GetChangeLog(boost::bind(RepositoryUtility::CommitChange, _1)); + GetChangeLog(boost::bind(RepositoryUtility::CommitChange, _1, _2)); return true; } @@ -322,7 +322,7 @@ void RepositoryUtility::CollectObjects(const String& object_file, std::vector& callback) +bool RepositoryUtility::GetChangeLog(const boost::function& callback) { std::vector changelog; String path = GetRepositoryChangeLogPath() + "/"; @@ -334,13 +334,14 @@ bool RepositoryUtility::GetChangeLog(const boost::functionGet("name"); @@ -369,11 +370,19 @@ void RepositoryUtility::CommitChange(const Dictionary::Ptr& change) attr = change->Get("attr"); } + bool success = false; + if (command == "add") { - AddObjectInternal(name, type, attr); + success = AddObjectInternal(name, type, attr); } else if (command == "remove") { - RemoveObjectInternal(name, type, attr); + success = RemoveObjectInternal(name, type, attr); + } + + if (success) { + Log(LogInformation, "cli") + << "Removing changelog file '" << path << "'."; + RemoveObjectFileInternal(path); } } diff --git a/lib/cli/repositoryutility.hpp b/lib/cli/repositoryutility.hpp index c0e608a22..757b5221d 100644 --- a/lib/cli/repositoryutility.hpp +++ b/lib/cli/repositoryutility.hpp @@ -76,8 +76,8 @@ private: static bool WriteObjectToRepositoryChangeLog(const String& path, const Dictionary::Ptr& item); static Dictionary::Ptr GetObjectFromRepositoryChangeLog(const String& filename); - static bool GetChangeLog(const boost::function& callback); - static void CommitChange(const Dictionary::Ptr& change); + static bool GetChangeLog(const boost::function& callback); + static void CommitChange(const Dictionary::Ptr& change, const String& path); static void CollectChange(const Dictionary::Ptr& change, Array::Ptr& changes); /* config print helpers */