Skip to content

Commit beb183f

Browse files
authored
remove dup codes (#411)
* remove dup codes * add cli diff unittest job * update python matrix * release v0.1.57
1 parent 9b75cab commit beb183f

17 files changed

Lines changed: 794 additions & 874 deletions

HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
33
Release History
44
===============
5+
0.1.57
6+
++++++
7+
* `azdev command-change meta-diff`: Remove duplicated meta-diff code and use azure-cli-diff-tool
8+
59
0.1.56
610
++++++
711
* Fix cmdcov issue(#410): Get config from github when get_cli_repo_path failed

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.56'
7+
__VERSION__ = '0.1.57'

azdev/operations/command_change/__init__.py

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,18 @@
66

77
# pylint: disable=no-else-return
88

9-
import json
10-
import os
119
import time
1210

13-
from deepdiff import DeepDiff
1411
from knack.log import get_logger
15-
12+
import azure_cli_diff_tool
1613
from azdev.utilities import display, require_azure_cli, heading, get_path_table, filter_by_git_diff
17-
from .custom import MetaChangeDetects, DiffExportFormat
18-
from .util import export_meta_changes_to_json, gen_commands_meta, get_commands_meta
14+
from .custom import DiffExportFormat, get_commands_meta
15+
from .util import export_commands_meta
1916
from ..statistics import _create_invoker_and_load_cmds, _get_command_source, \
2017
_command_codegen_info # pylint: disable=protected-access
2118
from ..statistics.util import filter_modules
2219

20+
2321
logger = get_logger(__name__)
2422

2523

@@ -117,28 +115,9 @@ def export_command_meta(modules=None, git_source=None, git_target=None, git_repo
117115

118116
commands_info.append(command_info)
119117
commands_meta = get_commands_meta(command_loader.command_group_table, commands_info, with_help, with_example)
120-
gen_commands_meta(commands_meta, meta_output_path)
118+
export_commands_meta(commands_meta, meta_output_path)
121119
display(f"Total Commands: {len(commands_info)} from {', '.join(selected_mod_names)} have been generated.")
122120

123121

124122
def cmp_command_meta(base_meta_file, diff_meta_file, only_break=False, output_type="text", output_file=None):
125-
if not os.path.exists(base_meta_file):
126-
raise Exception("base meta file needed")
127-
if not os.path.exists(diff_meta_file):
128-
raise Exception("diff meta file needed")
129-
start = time.time()
130-
with open(base_meta_file, "r") as g:
131-
command_tree_before = json.load(g)
132-
with open(diff_meta_file, "r") as g:
133-
command_tree_after = json.load(g)
134-
stop = time.time()
135-
logger.info('Command meta files loaded in %i sec', stop - start)
136-
diff = DeepDiff(command_tree_before, command_tree_after)
137-
if not diff:
138-
display(f"No meta diffs from {diff_meta_file} to {base_meta_file}")
139-
return export_meta_changes_to_json(None, output_file)
140-
else:
141-
detected_changes = MetaChangeDetects(diff, command_tree_before, command_tree_after)
142-
detected_changes.check_deep_diffs()
143-
result = detected_changes.export_meta_changes(only_break, output_type)
144-
return export_meta_changes_to_json(result, output_file)
123+
return azure_cli_diff_tool.meta_diff(base_meta_file, diff_meta_file, only_break, output_type, output_file)

0 commit comments

Comments
 (0)