Skip to content

Commit

Permalink
optimize change_log (#24252)
Browse files Browse the repository at this point in the history
* optimize change_log

* Update change_log.py

* Update code_report.py

* Update code_report.py

* Update code_report.py

* Update code_report.py

* Update code_report.py
  • Loading branch information
Wzb123456789 authored May 5, 2022
1 parent d4d93d7 commit daa7573
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tools/azure-sdk-tools/packaging_tools/change_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ def models(self, diff_entry):
self.breaking_changes.append(_MODEL_PARAM_CHANGE_REQUIRED.format(parameter_name, model_name))
return

def client(self):
self.breaking_changes.append(_CLIENT_SIGNATURE_CHANGE)
return

## Features
_ADD_OPERATION_GROUP = "Added operation group {}"
Expand All @@ -156,6 +159,7 @@ def models(self, diff_entry):
_REMOVE_OPERATION_GROUP = "Removed operation group {}"
_REMOVE_OPERATION = "Removed operation {}.{}"
_REMOVE_OPERATION_PARAM = "Operation {}.{} no longer has parameter {}"
_CLIENT_SIGNATURE_CHANGE = "Client name is changed"
_MODEL_SIGNATURE_CHANGE = "Model {} has a new signature"
_MODEL_PARAM_DELETE = "Model {} no longer has parameter {}"
_MODEL_PARAM_ADD_REQUIRED = "Model {} has a new required parameter {}"
Expand All @@ -174,6 +178,8 @@ def build_change_log(old_report, new_report):
change_log.operation(diff_line)
else:
change_log.models(diff_line)
if diff_line[0][0] == 'client':
change_log.client()

return change_log

Expand Down
8 changes: 7 additions & 1 deletion tools/azure-sdk-tools/packaging_tools/code_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,20 @@ def parse_input(input_parameter):


def create_empty_report():
return {"models": {"enums": {}, "exceptions": {}, "models": {}}, "operations": {}}
return {"client": {}, "models": {"enums": {}, "exceptions": {}, "models": {}}, "operations": {}}


def create_report(module_name: str) -> Dict[str, Any]:
module_to_generate = importlib.import_module(module_name)
client_name = getattr(module_to_generate, '__all__')

report = create_empty_report()

try:
report["client"] = client_name
except:
report["client"] = []

# Look for models first
model_names = [model_name for model_name in dir(module_to_generate.models) if model_name[0].isupper()]
for model_name in model_names:
Expand Down

0 comments on commit daa7573

Please sign in to comment.