summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-11-15 12:39:25 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-11-15 12:39:25 +0200
commit9deb34a844ec03383a2b51426aec521b899934f9 (patch)
tree8ea18f02b9f8e7440cb709e6edf6fed52eeb1ec5
parentf988aa9833cd337073451e6fa413a2358e8a4592 (diff)
downloadbdep-9deb34a844ec03383a2b51426aec521b899934f9.tar.gz
bdep-9deb34a844ec03383a2b51426aec521b899934f9.tar.xz
bdep-9deb34a844ec03383a2b51426aec521b899934f9.zip
Improve bdep-new diagnostics for when directory already contains project
-rw-r--r--bdep/new.cxx64
1 files changed, 33 insertions, 31 deletions
diff --git a/bdep/new.cxx b/bdep/new.cxx
index e97f0fb..05d3b7a 100644
--- a/bdep/new.cxx
+++ b/bdep/new.cxx
@@ -200,46 +200,48 @@ namespace bdep
prj = out;
}
- // Do some sanity check (nested packages, etc; you would be surprised what
- // people come up with).
+ // Create the output directory and do some sanity check (empty if exists,
+ // nested packages, etc; you would be surprised what people come up with).
//
- if (!o.no_checks ())
{
- project_package pp (
- find_project_package (out, true /* ignore_not_found */));
+ bool e (exists (out));
- if (o.package ())
+ if (e && !empty (out))
+ fail << "directory " << out << " already exists and is not empty";
+
+ if (!o.no_checks ())
{
- if (!pp.project.empty ())
+ project_package pp (
+ find_project_package (out, true /* ignore_not_found */));
+
+ if (o.package ())
{
- if (pp.project != prj)
- fail << prj << " is not a project directory" <<
- info << pp.project << " looks like a project directory";
-
- if (pp.package)
- fail << "package directory " << out << " is inside another "
- << "package directory " << prj / *pp.package <<
- info << "nested packages are not allowed";
+ if (!pp.project.empty ())
+ {
+ if (pp.project != prj)
+ fail << prj << " is not a project directory" <<
+ info << pp.project << " looks like a project directory";
+
+ if (pp.package)
+ fail << "package directory " << out << " is inside another "
+ << "package directory " << prj / *pp.package <<
+ info << "nested packages are not allowed";
+ }
+ else
+ warn << prj << " does not look like a project directory";
}
else
- warn << prj << " does not look like a project directory";
- }
- else
- {
- if (!pp.project.empty ())
- fail << "project directory " << out << " is inside another "
- << "project directory " << pp.project <<
- info << "nested projects are not allowed";
+ {
+ if (!pp.project.empty ())
+ fail << "project directory " << out << " is inside another "
+ << "project directory " << pp.project <<
+ info << "nested projects are not allowed";
+ }
}
- }
- // If the output directory already exists, make sure it is empty.
- // Otherwise create it.
- //
- if (!exists (out))
- mk (out);
- else if (!empty (out))
- fail << "directory " << out << " already exists";
+ if (!e)
+ mk (out);
+ }
// Initialize the version control system. Do it before writing anything
// ourselves in case it fails. Also, the email discovery may do the VCS