From 20a176680afb7cf8ceefbb28d15150bee05166af Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 28 Oct 2014 19:43:37 +0100 Subject: [PATCH] Cli: Bail early on 'repository commit' if changelog dir does not exist refs #7255 --- lib/cli/repositorycommitcommand.cpp | 6 ++++-- lib/cli/repositoryobjectcommand.cpp | 10 +++++----- lib/cli/repositoryutility.cpp | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/cli/repositorycommitcommand.cpp b/lib/cli/repositorycommitcommand.cpp index b29e94af6..04979cc4c 100644 --- a/lib/cli/repositorycommitcommand.cpp +++ b/lib/cli/repositorycommitcommand.cpp @@ -60,8 +60,10 @@ ImpersonationLevel RepositoryCommitCommand::GetImpersonationLevel(void) const */ int RepositoryCommitCommand::Run(const boost::program_options::variables_map& vm, const std::vector& ap) const { - /* create required repositories first, just in case */ - Utility::MkDirP(RepositoryUtility::GetRepositoryChangeLogPath(), 0750); + if (!Utility::PathExists(RepositoryUtility::GetRepositoryChangeLogPath())) { + std::cout << "Repository Changelog path '" << RepositoryUtility::GetRepositoryChangeLogPath() << "' does not exist. Add objects first!\n"; + return 1; + } if (vm.count("simulate")) { RepositoryUtility::PrintChangeLog(std::cout); diff --git a/lib/cli/repositoryobjectcommand.cpp b/lib/cli/repositoryobjectcommand.cpp index 36bfb6108..b8beb46b0 100644 --- a/lib/cli/repositoryobjectcommand.cpp +++ b/lib/cli/repositoryobjectcommand.cpp @@ -150,16 +150,16 @@ std::vector RepositoryObjectCommand::GetPositionalSuggestions(const Stri return CLICommand::GetPositionalSuggestions(word); } -int RepositoryObjectCommand::GetMaxArguments(void) const -{ - return -1; -} - ImpersonationLevel RepositoryObjectCommand::GetImpersonationLevel(void) const { return ImpersonateRoot; } +int RepositoryObjectCommand::GetMaxArguments(void) const +{ + return -1; +} + /** * The entry point for the "repository " CLI command. * diff --git a/lib/cli/repositoryutility.cpp b/lib/cli/repositoryutility.cpp index 5796155f7..a98fdf059 100644 --- a/lib/cli/repositoryutility.cpp +++ b/lib/cli/repositoryutility.cpp @@ -629,7 +629,7 @@ void RepositoryUtility::SerializeObject(std::ostream& fp, const String& name, co } BOOST_FOREACH(const Dictionary::Pair& kv, object) { - if (kv.first == "import" || kv.first == "name") { + if (kv.first == "import" || kv.first == "name" || kv.first == "__name") { continue; } else { fp << "\t" << kv.first << " = ";