[PATCH] bitbake-setup: preserve VSCode extension recommendation
Giancarlo Cicellyn Comneno <[email protected]>
| Newsgroups | org.openembedded.lists.bitbake-devel |
|---|---|
| Message-ID | <[email protected]> |
configure_vscode() initializes the Yocto BitBake extension recommendation when creating a new workspace. When an existing workspace is loaded, its extensions section replaces that initial value, so the managed recommendation can disappear. Merge the managed recommendation into the existing recommendations while preserving recommendations added by the user. Extend test_vscode to cover both cases. Tests: LC_ALL=C LANG=C bitbake-selftest bb.tests.setup AI-Generated: Uses OpenAI ChatGPT Signed-off-by: Giancarlo Cicellyn Comneno <[email protected]> --- bin/bitbake-setup | 5 +++++ lib/bb/tests/setup.py | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/bin/bitbake-setup b/bin/bitbake-setup index 34260139c..9e5f9b31c 100755 --- a/bin/bitbake-setup +++ b/bin/bitbake-setup @@ -716,6 +716,11 @@ def configure_vscode(setupdir, layerdir, builddir, init_script): else: logger.debug("configure_vscode: creating new workspace file: {}".format(workspace_file)) + # Update extension recommendations + recommendations = workspace.setdefault("extensions", {}).setdefault("recommendations", []) + if "yocto-project.yocto-bitbake" not in recommendations: + recommendations.append("yocto-project.yocto-bitbake") + # Update folders existing_folders = workspace.get("folders", []) new_folders = [{"name": "conf", "path": conf_path}] diff --git a/lib/bb/tests/setup.py b/lib/bb/tests/setup.py index 53a07ee3a..0dfbd910e 100644 --- a/lib/bb/tests/setup.py +++ b/lib/bb/tests/setup.py @@ -644,6 +644,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) # user-added folders and settings while still rewriting managed ones workspace['folders'].append({"name": "user-folder", "path": "user/custom"}) workspace['settings']['my.user.setting'] = 'preserved' + workspace['extensions']['recommendations'] = ['user.example-extension'] with open(workspace_file, 'w') as f: json.dump(workspace, f, indent=4) @@ -658,6 +659,16 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) "User-added folder was removed during update") self.assertIn('my.user.setting', updated['settings'], "User-added setting was removed during update") + self.assertIn( + 'yocto-project.yocto-bitbake', + updated.get('extensions', {}).get('recommendations', []), + "Managed BitBake extension recommendation was not restored during update" + ) + self.assertIn( + 'user.example-extension', + updated.get('extensions', {}).get('recommendations', []), + "User-added extension recommendation was removed during update" + ) # update with a corrupt workspace file should log an error and leave it unchanged self.add_file_to_testrepo('test-file', 'updated-again\n') -- 2.43.0