diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-04-17 16:07:43 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-04-17 16:24:40 +0900 |
commit | c9b3aad71015cc713eda05386daa950495e11a76 (patch) | |
tree | ad29c2f9a22885e150efb1fd3ccf323b103d8f6c | |
parent | 9cf8d35fce45b85de3535815501af92e175faa3b (diff) | |
download | buildstream-c9b3aad71015cc713eda05386daa950495e11a76.tar.gz |
_frontend: Earlier assertion for `bst workspace open` when directory is not empty
This just raises the error to the user that the checkout directory
where they intend to create a workspace in is not empty, a little
bit earlier, without bothering to initialize the pipeline first.
-rw-r--r-- | buildstream/_frontend/app.py | 3 | ||||
-rw-r--r-- | buildstream/_frontend/cli.py | 10 |
2 files changed, 10 insertions, 3 deletions
diff --git a/buildstream/_frontend/app.py b/buildstream/_frontend/app.py index 767e0cf1b..fe2c460c5 100644 --- a/buildstream/_frontend/app.py +++ b/buildstream/_frontend/app.py @@ -474,9 +474,6 @@ class App(): workspace = self.project.workspaces.create_workspace(target.name, workdir) if not no_checkout: - if not force and os.listdir(directory): - raise AppError("Checkout directory is not empty: {}".format(directory)) - with target.timed_activity("Staging sources to {}".format(directory)): target._open_workspace() diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py index fadfaf59b..9720bc44e 100644 --- a/buildstream/_frontend/cli.py +++ b/buildstream/_frontend/cli.py @@ -613,6 +613,16 @@ def workspace(): def workspace_open(app, no_checkout, force, track_, element, directory): """Open a workspace for manual source modification""" + if os.path.exists(directory): + + if not os.path.isdir(directory): + click.echo("Checkout directory is not a directory: {}".format(directory), err=True) + sys.exit(-1) + + if not (no_checkout or force) and os.listdir(directory): + click.echo("Checkout directory is not empty: {}".format(directory), err=True) + sys.exit(-1) + with app.initialized((element,), rewritable=track_, track_elements=[element] if track_ else None): app.open_workspace(directory, no_checkout, track_, force) |