mbox series

[v2,00/10] bitbake-setup: improvements, VSCode workspace generation

Message ID 20260325071342.47272-1-adrian.freihofer@siemens.com
Headers show
Series bitbake-setup: improvements, VSCode workspace generation | expand

Message

AdrianF March 25, 2026, 6:51 a.m. UTC
From: Adrian Freihofer <adrian.freihofer@siemens.com>

Comparison to v1:
- Rebased on latest master
- Addressed feedback from Richard:
  - There is now a bb.fetch2.LocalModificationsError
  - Adapted test accordingly (changed order of commits because of that)
- Addressed feedback from Alexander:
  - run configure_vscode() inside setup_bitbake_build(), simplifying the logic
  - Remove the --init-vscode option from update (only init supports it now)
  - Renamed --rebase-strategy to --rebase-conflicts-strategy with
    'abort' and 'backup' options
  - Adapted tests accordingly


Adds:
- Tests for bitbake fetcher unpack_update: add GitUnpackUpdateTest covering
  the full unpack_update workflow — fast-forward rebase with local commits,
  dldir remote setup, conflict detection, staged/modified file blocking,
  untracked file handling, shallow clone rejection, and stale dldir remote.

- Some findings in bitbake-setup: always restore sys.stdout after fetch log
  redirection; fix dead guards in check_setupdir_files; clean up imports;
  turn unhandled Exception in main() into a clean ERROR log line and non-zero
  exit instead of a raw traceback; report local modifications that block an
  update with an actionable error message.

- VSCode workspace generation (--init-vscode / --no-init-vscode):
  bitbake-setup init and update can generate a bitbake.code-workspace file
  that configures the Yocto BitBake VS Code extension, Python analysis paths,
  file associations, and folders for each layer repository. User-added folders
  and settings are preserved on update; a corrupt workspace file is detected
  and left unchanged.

- bitbake-setup rebase strategy (--rebase-conflicts-strategy abort|backup):
  When unpack_update() cannot rebase a layer repository due to uncommitted
  local modifications or a committed local change that causes a rebase
  conflict, the default 'abort' strategy aborts with a clear, actionable
  error message. The 'backup' strategy renames the directory to a timestamped
  backup and re-clones from upstream instead.


Testing
- bitbake-selftest bb.tests.fetch.GitUnpackUpdateTest
- bitbake-selftest bb.tests.setup
- Manual testing with --rebase-conflicts-strategy abort:
  - bitbake-setup init
  - cd layers/openembedded-core
  - git checkout older commit
  - modify a file to provoke a conflict without committing
  - bitbake-setup update
    --> fails with a clear message about local modifications blocking the update
  - git stash
    bitbake-setup update
    --> succeeds with a fast-forward update
    git stash pop
  ==> Workflow feels smooth :-)

- Manual testing with --rebase-conflicts-strategy backup (uncommitted changes):
  - bitbake-setup init
  - cd layers/openembedded-core
  - git checkout older commit
  - modify a file to provoke a conflict without committing
  - bitbake-setup update --rebase-conflicts-strategy backup
    --> succeeds with a backup and a fresh clone from upstream
  ==> Workflow feels smooth :-)

- Manual testing with --rebase-conflicts-strategy backup (committed conflict):
  - bitbake-setup init
  - cd layers/openembedded-core
  - edit a file to provoke a conflict
  - bitbake-setup update --rebase-conflicts-strategy backup
    --> succeeds: the conflicting directory is backed up and re-cloned cleanly
  ==> Workflow feels smooth, but we probably need to improve it later
    - VSCode shows the backup directory as a workspace folder, that's fine
    - Who is going to delete the backup later? In VSCode it's possible to
      click "Remove folder from workspace" and then delete it manually on the command line
    Some features like bitbake-setup update --remove-backups interactively might be nice



Adrian Freihofer (10):
  fetch2: add LocalModificationsError for uncommitted changes blocking
    update
  bitbake-selftest: add GitUnpackUpdateTest
  tests/fetch: remove unused import, fix trailing whitespace
  bitbake-setup: always restore sys.stdout
  tests/setup: cleanup imports
  tests/setup: fix dead check_setupdir_files guards
  bitbake-setup: generate config files for VSCode
  tests/setup: add test_vscode for VSCode workspace generation
  bitbake-setup: add --rebase-conflicts-strategy to the update command
  tests/setup: add test_update_rebase_conflicts_strategy

 bin/bitbake-setup         | 223 ++++++++++++++-
 lib/bb/fetch2/__init__.py |   8 +
 lib/bb/fetch2/git.py      |   2 +-
 lib/bb/tests/fetch.py     | 563 +++++++++++++++++++++++++++++++++++++-
 lib/bb/tests/setup.py     | 195 ++++++++++++-
 5 files changed, 965 insertions(+), 26 deletions(-)