[Notes] [Git][BuildStream/buildstream][aevri/prompt-config] Add prompt.workspace-... options



Title: GitLab

Angelos Evripiotis pushed to branch aevri/prompt-config at BuildStream / buildstream

Commits:

4 changed files:

Changes:

  • NEWS
    ... ... @@ -45,9 +45,11 @@ buildstream 1.3.1
    45 45
         instead of just a specially-formatted build-root with a `root` and `scratch`
    
    46 46
         subdirectory.
    
    47 47
     
    
    48
    -  o The buildstream.conf file learned a new 'prompt.auto-init' option. This
    
    49
    -    allows users to suppress prompts for automatically running 'bst init' if we
    
    50
    -    were unable to resolve the project.
    
    48
    +  o The buildstream.conf file learned new 'prompt.auto-init',
    
    49
    +    'prompt.really-workspace-close-remove-dir', and
    
    50
    +    'prompt.really-workspace-reset-hard' options. These allow users to suppress
    
    51
    +    certain confirmation prompts, e.g. double-checking that the user meant to
    
    52
    +    run the command as typed.
    
    51 53
     
    
    52 54
       o Due to the element `build tree` being cached in the respective artifact their
    
    53 55
         size in some cases has significantly increased. In *most* cases the build trees
    

  • buildstream/_context.py
    ... ... @@ -114,6 +114,14 @@ class Context():
    114 114
             # invoked outside of a directory where we can resolve the project.
    
    115 115
             self.prompt_auto_init = None
    
    116 116
     
    
    117
    +        # Boolean, whether we double-check with the user that they meant to
    
    118
    +        # remove a workspace directory.
    
    119
    +        self.prompt_workspace_close_remove_dir = None
    
    120
    +
    
    121
    +        # Boolean, whether we double-check with the user that they meant to do
    
    122
    +        # a hard reset of a workspace, potentially losing changes.
    
    123
    +        self.prompt_workspace_reset_hard = None
    
    124
    +
    
    117 125
             # Whether elements must be rebuilt when their dependencies have changed
    
    118 126
             self._strict_build_plan = None
    
    119 127
     
    
    ... ... @@ -235,9 +243,16 @@ class Context():
    235 243
             #
    
    236 244
             prompt = _yaml.node_get(
    
    237 245
                 defaults, Mapping, 'prompt')
    
    238
    -        _yaml.node_validate(prompt, ['auto-init'])
    
    246
    +        _yaml.node_validate(prompt, [
    
    247
    +            'auto-init', 'really-workspace-close-remove-dir',
    
    248
    +            'really-workspace-reset-hard',
    
    249
    +        ])
    
    239 250
             self.prompt_auto_init = _node_get_option_str(
    
    240 251
                 prompt, 'auto-init', ['ask', 'no']) == 'ask'
    
    252
    +        self.prompt_workspace_close_remove_dir = _node_get_option_str(
    
    253
    +            prompt, 'really-workspace-close-remove-dir', ['ask', 'yes']) == 'ask'
    
    254
    +        self.prompt_workspace_reset_hard = _node_get_option_str(
    
    255
    +            prompt, 'really-workspace-reset-hard', ['ask', 'yes']) == 'ask'
    
    241 256
     
    
    242 257
             # Load per-projects overrides
    
    243 258
             self._project_overrides = _yaml.node_get(defaults, Mapping, 'projects', default_value={})
    

  • buildstream/_frontend/cli.py
    ... ... @@ -772,7 +772,7 @@ def workspace_close(app, remove_dir, all_, elements):
    772 772
             if nonexisting:
    
    773 773
                 raise AppError("Workspace does not exist", detail="\n".join(nonexisting))
    
    774 774
     
    
    775
    -        if app.interactive and remove_dir:
    
    775
    +        if app.interactive and remove_dir and app.context.prompt_workspace_close_remove_dir:
    
    776 776
                 if not click.confirm('This will remove all your changes, are you sure?'):
    
    777 777
                     click.echo('Aborting', err=True)
    
    778 778
                     sys.exit(-1)
    
    ... ... @@ -806,7 +806,7 @@ def workspace_reset(app, soft, track_, all_, elements):
    806 806
             if all_ and not app.stream.workspace_exists():
    
    807 807
                 raise AppError("No open workspaces to reset")
    
    808 808
     
    
    809
    -        if app.interactive and not soft:
    
    809
    +        if app.interactive and not soft and app.context.prompt_workspace_reset_hard:
    
    810 810
                 if not click.confirm('This will remove all your changes, are you sure?'):
    
    811 811
                     click.echo('Aborting', err=True)
    
    812 812
                     sys.exit(-1)
    

  • buildstream/data/userconfig.yaml
    ... ... @@ -116,3 +116,19 @@ prompt:
    116 116
       #  no  - Never create the project.
    
    117 117
       #
    
    118 118
       auto-init: ask
    
    119
    +
    
    120
    +  # Whether to really proceed with 'bst workspace close --remove-dir' removing
    
    121
    +  # a workspace directory, potentially losing changes.
    
    122
    +  #
    
    123
    +  #  ask - Ask the user if they are sure.
    
    124
    +  #  yes - Always remove, without asking.
    
    125
    +  #
    
    126
    +  really-workspace-close-remove-dir: ask
    
    127
    +
    
    128
    +  # Whether to really proceed with 'bst workspace reset' doing a hard reset of
    
    129
    +  # a workspace, potentially losing changes.
    
    130
    +  #
    
    131
    +  #  ask - Ask the user if they are sure.
    
    132
    +  #  yes - Always hard reset, without asking.
    
    133
    +  #
    
    134
    +  really-workspace-reset-hard: ask



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]