Skip to content

Commit fb53fcf

Browse files
authored
Update Extension Upcoming Breaking Changes extraction Scope (#507)
* Support Extension in Upcoming Breaking Change extraction. * Add History Note
1 parent d71c955 commit fb53fcf

4 files changed

Lines changed: 38 additions & 16 deletions

File tree

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
33
Release History
44
===============
5+
0.1.95
6+
++++++
7+
* `azdev generate-breaking-change-report`: Extracts upcoming breaking changes in extensions, regardless of the target version set
8+
* `azdev generate-breaking-change-report`: Fix collecting announcement starting with `az`
9+
10+
511
0.1.94
612
++++++
713
* `azdev command-change meta-export`: Enable meta exporting for extension installed using `.whl` package by `include_whl_extensions`

azdev/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# license information.
55
# -----------------------------------------------------------------------------
66

7-
__VERSION__ = '0.1.94'
7+
__VERSION__ = '0.1.95'

azdev/operations/breaking_change/__init__.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from azdev.operations.statistics import _create_invoker_and_load_cmds # pylint: disable=protected-access
1515
from azdev.utilities import require_azure_cli, display, heading, output, calc_selected_mod_names
16+
from azdev.utilities.path import calc_selected_modules
1617

1718
# pylint: disable=no-else-return
1819

@@ -68,8 +69,9 @@ def _handle_custom_breaking_changes(module, command):
6869
"""
6970
from azure.cli.core.breaking_change import upcoming_breaking_changes
7071
yield from _handle_custom_breaking_change(module, command, upcoming_breaking_changes.get(command))
72+
yield from _handle_custom_breaking_change(module, command, upcoming_breaking_changes.get(f'az {command}'))
7173
for key in upcoming_breaking_changes:
72-
if key.startswith(command + '.'):
74+
if key.startswith(command + '.') or key.startswith(f'az {command}.'):
7375
yield from _handle_custom_breaking_change(module, command, upcoming_breaking_changes[key])
7476

7577

@@ -249,9 +251,7 @@ def _handle_core(source):
249251
display('Core finished loaded in {} sec'.format(stop - start))
250252

251253

252-
def _handle_upcoming_breaking_changes(selected_mod_names, source):
253-
command_loader = _load_commands()
254-
254+
def _handle_upcoming_breaking_changes(command_loader, selected_mod_names, source):
255255
if 'core' in selected_mod_names or 'azure-cli-core' in selected_mod_names:
256256
yield from _handle_core(source)
257257

@@ -285,13 +285,13 @@ def _filter_breaking_changes(iterator, max_version=None):
285285
# pylint: disable=unnecessary-lambda-assignment
286286
def _group_breaking_change_items(iterator, group_by_version=False):
287287
if group_by_version:
288-
upcoming_breaking_changes = defaultdict( # module to command
289-
lambda: defaultdict( # command to version
290-
lambda: {'group_ref': None, 'items': defaultdict( # version to list of breaking changes
288+
upcoming_breaking_changes = defaultdict( # module to command
289+
lambda: defaultdict( # command to version
290+
lambda: {'group_ref': None, 'items': defaultdict( # version to list of breaking changes
291291
lambda: [])}))
292292
else:
293-
upcoming_breaking_changes = defaultdict( # module to command
294-
lambda: defaultdict( # command to list of breaking changes
293+
upcoming_breaking_changes = defaultdict( # module to command
294+
lambda: defaultdict( # command to list of breaking changes
295295
lambda: {'group_ref': None, 'items': []}))
296296
for item in iterator:
297297
version = item.target_version if item.target_version else 'Unspecific'
@@ -313,14 +313,24 @@ def collect_upcoming_breaking_changes(modules=None, target_version='NextWindow',
313313

314314
require_azure_cli()
315315

316-
selected_mod_names = calc_selected_mod_names(modules)
316+
selected_modules = calc_selected_modules(modules)
317+
cli_mod_names = list(selected_modules['core'].keys()) + list(selected_modules['mod'].keys())
318+
ext_mod_names = list(selected_modules['ext'].keys())
317319

318-
if selected_mod_names:
319-
display('Modules selected: {}\n'.format(', '.join(selected_mod_names)))
320+
if cli_mod_names or ext_mod_names:
321+
display('Modules selected: {}\n'.format(', '.join(cli_mod_names + ext_mod_names)))
322+
323+
command_loader = _load_commands()
320324

321325
heading('Collecting Breaking Change Pre-announcement')
322-
breaking_changes = _handle_upcoming_breaking_changes(selected_mod_names, source)
323-
breaking_changes = _filter_breaking_changes(breaking_changes, target_version)
326+
breaking_changes = []
327+
if cli_mod_names:
328+
cli_breaking_changes = _handle_upcoming_breaking_changes(command_loader, cli_mod_names, source)
329+
cli_breaking_changes = _filter_breaking_changes(cli_breaking_changes, target_version)
330+
breaking_changes.extend(cli_breaking_changes)
331+
if ext_mod_names:
332+
ext_breaking_changes = _handle_upcoming_breaking_changes(command_loader, ext_mod_names, 'pre_announce')
333+
breaking_changes.extend(ext_breaking_changes)
324334
breaking_changes = _group_breaking_change_items(breaking_changes, group_by_version)
325335
if output_format == 'structure':
326336
return breaking_changes

azdev/utilities/path.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def _update_table(package_paths, key):
265265
return table
266266

267267

268-
def calc_selected_mod_names(modules=None):
268+
def calc_selected_modules(modules=None):
269269
# allow user to run only on CLI or extensions
270270
cli_only = modules == ['CLI']
271271
ext_only = modules == ['EXT']
@@ -280,6 +280,12 @@ def calc_selected_mod_names(modules=None):
280280
selected_modules['core'] = {}
281281
selected_modules['mod'] = {}
282282

283+
return selected_modules
284+
285+
286+
def calc_selected_mod_names(modules=None):
287+
selected_modules = calc_selected_modules(modules)
288+
283289
if not any(selected_modules.values()):
284290
logger.warning('No commands selected to check.')
285291

0 commit comments

Comments
 (0)