[Notes] [Git][BuildStream/buildstream][master] 2 commits: userconfig: rm really-workspace-close-project-inaccessible



Title: GitLab

Angelos Evripiotis pushed to branch master at BuildStream / buildstream

Commits:

4 changed files:

Changes:

  • buildstream/_context.py
    ... ... @@ -124,10 +124,6 @@ class Context():
    124 124
             # Whether or not to cache build trees on artifact creation
    
    125 125
             self.cache_buildtrees = None
    
    126 126
     
    
    127
    -        # Boolean, whether we double-check with the user that they meant to
    
    128
    -        # close the workspace when they're using it to access the project.
    
    129
    -        self.prompt_workspace_close_project_inaccessible = None
    
    130
    -
    
    131 127
             # Whether elements must be rebuilt when their dependencies have changed
    
    132 128
             self._strict_build_plan = None
    
    133 129
     
    
    ... ... @@ -248,22 +244,6 @@ class Context():
    248 244
             self.sched_pushers = _yaml.node_get(scheduler, int, 'pushers')
    
    249 245
             self.sched_network_retries = _yaml.node_get(scheduler, int, 'network-retries')
    
    250 246
     
    
    251
    -        # Load prompt preferences
    
    252
    -        #
    
    253
    -        # We convert string options to booleans here, so we can be both user
    
    254
    -        # and coder-friendly. The string options are worded to match the
    
    255
    -        # responses the user would give at the cli, for least surprise. The
    
    256
    -        # booleans are converted here because it's easiest to eyeball that the
    
    257
    -        # strings are right.
    
    258
    -        #
    
    259
    -        prompt = _yaml.node_get(
    
    260
    -            defaults, Mapping, 'prompt')
    
    261
    -        _yaml.node_validate(prompt, [
    
    262
    -            'really-workspace-close-project-inaccessible',
    
    263
    -        ])
    
    264
    -        self.prompt_workspace_close_project_inaccessible = _node_get_option_str(
    
    265
    -            prompt, 'really-workspace-close-project-inaccessible', ['ask', 'yes']) == 'ask'
    
    266
    -
    
    267 247
             # Load per-projects overrides
    
    268 248
             self._project_overrides = _yaml.node_get(defaults, Mapping, 'projects', default_value={})
    
    269 249
     
    

  • buildstream/_frontend/cli.py
    ... ... @@ -814,6 +814,8 @@ def workspace_open(app, no_checkout, force, track_, directory, elements):
    814 814
     def workspace_close(app, remove_dir, all_, elements):
    
    815 815
         """Close a workspace"""
    
    816 816
     
    
    817
    +    removed_required_element = False
    
    818
    +
    
    817 819
         with app.initialized():
    
    818 820
             if not (all_ or elements):
    
    819 821
                 # NOTE: I may need to revisit this when implementing multiple projects
    
    ... ... @@ -840,18 +842,20 @@ def workspace_close(app, remove_dir, all_, elements):
    840 842
             for element_name in elements:
    
    841 843
                 if not app.stream.workspace_exists(element_name):
    
    842 844
                     nonexisting.append(element_name)
    
    843
    -            if (app.stream.workspace_is_required(element_name) and app.interactive and
    
    844
    -                    app.context.prompt_workspace_close_project_inaccessible):
    
    845
    -                click.echo("Removing '{}' will prevent you from running "
    
    846
    -                           "BuildStream commands from the current directory".format(element_name))
    
    847
    -                if not click.confirm('Are you sure you want to close this workspace?'):
    
    848
    -                    click.echo('Aborting', err=True)
    
    849
    -                    sys.exit(-1)
    
    850 845
             if nonexisting:
    
    851 846
                 raise AppError("Workspace does not exist", detail="\n".join(nonexisting))
    
    852 847
     
    
    853 848
             for element_name in elements:
    
    854 849
                 app.stream.workspace_close(element_name, remove_dir=remove_dir)
    
    850
    +            if app.stream.workspace_is_required(element_name):
    
    851
    +                removed_required_element = True
    
    852
    +
    
    853
    +    # This message is echo'd last, as it's most relevant to the next
    
    854
    +    # thing the user will type.
    
    855
    +    if removed_required_element:
    
    856
    +        click.echo(
    
    857
    +            "Removed '{}', therefore you can no longer run BuildStream "
    
    858
    +            "commands from the current directory.".format(element_name), err=True)
    
    855 859
     
    
    856 860
     
    
    857 861
     ##################################################################
    

  • buildstream/data/userconfig.yaml
    ... ... @@ -111,20 +111,3 @@ logging:
    111 111
       message-format: |
    
    112 112
     
    
    113 113
         [%{elapsed}][%{key}][%{element}] %{action} %{message}
    114
    -
    
    115
    -#
    
    116
    -#    Prompt overrides
    
    117
    -#
    
    118
    -# Here you can suppress 'are you sure?' and other kinds of prompts by supplying
    
    119
    -# override values. Note that e.g. 'yes' and 'no' have the same meaning here as
    
    120
    -# they do in the actual cli prompt.
    
    121
    -#
    
    122
    -prompt:
    
    123
    -
    
    124
    -  # Whether to really proceed with 'bst workspace close' when doing so would
    
    125
    -  # stop them from running bst commands in this workspace.
    
    126
    -  #
    
    127
    -  #  ask - Ask the user if they are sure.
    
    128
    -  #  yes - Always close, without asking.
    
    129
    -  #
    
    130
    -  really-workspace-close-project-inaccessible: ask

  • tests/frontend/workspace.py
    ... ... @@ -1184,6 +1184,7 @@ def test_external_close_other(cli, datafiles, tmpdir_factory):
    1184 1184
     
    
    1185 1185
         result = cli.run(project=project, args=['-C', alpha_workspace, 'workspace', 'close', beta_element])
    
    1186 1186
         result.assert_success()
    
    1187
    +    assert 'you can no longer run BuildStream' not in result.stderr
    
    1187 1188
     
    
    1188 1189
     
    
    1189 1190
     @pytest.mark.datafiles(DATA_DIR)
    
    ... ... @@ -1199,6 +1200,7 @@ def test_external_close_self(cli, datafiles, tmpdir_factory, guess_element):
    1199 1200
     
    
    1200 1201
         result = cli.run(project=project, args=['-C', alpha_workspace, 'workspace', 'close'] + arg_elm)
    
    1201 1202
         result.assert_success()
    
    1203
    +    assert 'you can no longer run BuildStream' in result.stderr
    
    1202 1204
     
    
    1203 1205
     
    
    1204 1206
     @pytest.mark.datafiles(DATA_DIR)
    



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