summaryrefslogtreecommitdiff
path: root/buildstream
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2018-10-19 18:48:38 +0100
committerAngelos Evripiotis <jevripiotis@bloomberg.net>2018-11-20 11:43:49 +0000
commit7ae3a3d2433f0909a6c4d43655b8fff95fb8c318 (patch)
tree4ae64f1775a4f82de378bb4d87e85ac025a4cea4 /buildstream
parent27ca65931d3cf6cf897b623f21ba2363f3c54029 (diff)
downloadbuildstream-7ae3a3d2433f0909a6c4d43655b8fff95fb8c318.tar.gz
Add prompt.workspace-... options
Provide options in project.conf to disable the 'Are you sure ...' prompts when making destructive changes: - Add prompt.really-workspace-close-remove-dir - Add prompt.really-workspace-reset-hard Add a NEWS item for these.
Diffstat (limited to 'buildstream')
-rw-r--r--buildstream/_context.py17
-rw-r--r--buildstream/_frontend/cli.py4
-rw-r--r--buildstream/data/userconfig.yaml16
3 files changed, 34 insertions, 3 deletions
diff --git a/buildstream/_context.py b/buildstream/_context.py
index 9bb261b62..7a47a30d3 100644
--- a/buildstream/_context.py
+++ b/buildstream/_context.py
@@ -114,6 +114,14 @@ class Context():
# invoked outside of a directory where we can resolve the project.
self.prompt_auto_init = None
+ # Boolean, whether we double-check with the user that they meant to
+ # remove a workspace directory.
+ self.prompt_workspace_close_remove_dir = None
+
+ # Boolean, whether we double-check with the user that they meant to do
+ # a hard reset of a workspace, potentially losing changes.
+ self.prompt_workspace_reset_hard = None
+
# Whether elements must be rebuilt when their dependencies have changed
self._strict_build_plan = None
@@ -235,9 +243,16 @@ class Context():
#
prompt = _yaml.node_get(
defaults, Mapping, 'prompt')
- _yaml.node_validate(prompt, ['auto-init'])
+ _yaml.node_validate(prompt, [
+ 'auto-init', 'really-workspace-close-remove-dir',
+ 'really-workspace-reset-hard',
+ ])
self.prompt_auto_init = _node_get_option_str(
prompt, 'auto-init', ['ask', 'no']) == 'ask'
+ self.prompt_workspace_close_remove_dir = _node_get_option_str(
+ prompt, 'really-workspace-close-remove-dir', ['ask', 'yes']) == 'ask'
+ self.prompt_workspace_reset_hard = _node_get_option_str(
+ prompt, 'really-workspace-reset-hard', ['ask', 'yes']) == 'ask'
# Load per-projects overrides
self._project_overrides = _yaml.node_get(defaults, Mapping, 'projects', default_value={})
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index 725dc8c1d..92abd96e8 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -772,7 +772,7 @@ def workspace_close(app, remove_dir, all_, elements):
if nonexisting:
raise AppError("Workspace does not exist", detail="\n".join(nonexisting))
- if app.interactive and remove_dir:
+ if app.interactive and remove_dir and app.context.prompt_workspace_close_remove_dir:
if not click.confirm('This will remove all your changes, are you sure?'):
click.echo('Aborting', err=True)
sys.exit(-1)
@@ -806,7 +806,7 @@ def workspace_reset(app, soft, track_, all_, elements):
if all_ and not app.stream.workspace_exists():
raise AppError("No open workspaces to reset")
- if app.interactive and not soft:
+ if app.interactive and not soft and app.context.prompt_workspace_reset_hard:
if not click.confirm('This will remove all your changes, are you sure?'):
click.echo('Aborting', err=True)
sys.exit(-1)
diff --git a/buildstream/data/userconfig.yaml b/buildstream/data/userconfig.yaml
index 0e6581cb7..dfc18545e 100644
--- a/buildstream/data/userconfig.yaml
+++ b/buildstream/data/userconfig.yaml
@@ -116,3 +116,19 @@ prompt:
# no - Never create the project.
#
auto-init: ask
+
+ # Whether to really proceed with 'bst workspace close --remove-dir' removing
+ # a workspace directory, potentially losing changes.
+ #
+ # ask - Ask the user if they are sure.
+ # yes - Always remove, without asking.
+ #
+ really-workspace-close-remove-dir: ask
+
+ # Whether to really proceed with 'bst workspace reset' doing a hard reset of
+ # a workspace, potentially losing changes.
+ #
+ # ask - Ask the user if they are sure.
+ # yes - Always hard reset, without asking.
+ #
+ really-workspace-reset-hard: ask