Skip to content

Commit

Permalink
[Packaging_Tools] Update change_log (#23801)
Browse files Browse the repository at this point in the history
* update change_log

* update change_log

* update raise error msg

* Update tools/azure-sdk-tools/packaging_tools/change_log.py

Co-authored-by: Yuchao Yan <[email protected]>

* update

* update

Co-authored-by: Yuchao Yan <[email protected]>
  • Loading branch information
BigCat20196 and msyyc authored Apr 13, 2022
1 parent 6a853e6 commit 394c396
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions tools/azure-sdk-tools/packaging_tools/change_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ def build_md(self):
self.sort()
buffer = []
if self.features:
_build_md(self.features, "**Features**", buffer)
_build_md(sorted(set(self.features), key=self.features.index), "**Features**", buffer)
if self.breaking_changes:
_build_md(self.breaking_changes, "**Breaking changes**", buffer)
_build_md(sorted(set(self.breaking_changes), key=self.breaking_changes.index), "**Breaking changes**", buffer)
if not (self.features or self.breaking_changes) and self.optional_features:
_build_md(self.optional_features, "**Features**", buffer)
_build_md(sorted(set(self.optional_features), key=self.optional_features.index), "**Features**", buffer)

return "\n".join(buffer).strip()

Expand Down Expand Up @@ -79,8 +79,18 @@ def operation(self, diff_entry):
# Ignore change in metadata for now, they have no impact
return

# So method signaure changed. Be vague for now
self.breaking_changes.append(_SIGNATURE_CHANGE.format(operation_name, function_name))
if remaining_path[0] == "parameters":
old_parameters_list = self._old_report["operations"][operation_name]["functions"][function_name]['parameters']
new_parameters_list = self._new_report["operations"][operation_name]["functions"][function_name]['parameters']
old_parameters = {param_name['name'] for param_name in old_parameters_list}
new_parameters = {param_name['name'] for param_name in new_parameters_list}
# The new parameter is optional or not. Be breaking change for now.
for removed_parameter in old_parameters - new_parameters:
self.breaking_changes.append(_REMOVE_OPERATION_PARAM.format(operation_name, function_name, removed_parameter))
for added_parameter in new_parameters - old_parameters:
self.breaking_changes.append(_ADD_OPERATION_PARAM.format(operation_name, function_name,added_parameter))
return
raise NotImplementedError(f"Other situations. Be err for now: {str(remaining_path)}")

def models(self, diff_entry):
path, is_deletion = self._unpack_diff_entry(diff_entry)
Expand Down Expand Up @@ -138,13 +148,14 @@ def models(self, diff_entry):
## Features
_ADD_OPERATION_GROUP = "Added operation group {}"
_ADD_OPERATION = "Added operation {}.{}"
_ADD_OPERATION_PARAM = "Operation {}.{} has a new parameter {}"
_MODEL_PARAM_ADD = "Model {} has a new parameter {}"
_MODEL_ADD = "Added model {}"

## Breaking Changes
_REMOVE_OPERATION_GROUP = "Removed operation group {}"
_REMOVE_OPERATION = "Removed operation {}.{}"
_SIGNATURE_CHANGE = "Operation {}.{} has a new signature"
_REMOVE_OPERATION_PARAM = "Operation {}.{} no longer has parameter {}"
_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 Down

0 comments on commit 394c396

Please sign in to comment.