def _detect_modified_command()

in azdev/operations/linter/linter.py [0:0]


    def _detect_modified_command(self):
        modified_commands = set()
        diff_patches = diff_branch_file_patch(repo=self.git_repo, target=self.git_target, source=self.git_source)
        for change in diff_patches:
            if not change.b_path or not change.diff:
                continue
            file_path, filename = self._split_path(change.b_path)
            if "commands.py" not in filename and "aaz" not in file_path:
                continue
            current_lines = self._read_blob_lines(change.b_blob)
            patch = change.diff.decode("utf-8")
            patch_lines = patch.splitlines()
            if 'commands.py' in filename:
                added_lines = [line for line in patch_lines if line.startswith('+') and not line.startswith('+++')]
                for line in added_lines:
                    if aaz_custom_command := search_aaz_custom_command(line):
                        modified_commands.add(aaz_custom_command)

                for row_num, line in enumerate(patch_lines):
                    if not line.startswith("+") or line.startswith('+++'):
                        continue
                    manual_command_suffix = search_command(line)
                    if manual_command_suffix:
                        idx = self._get_line_number(patch_lines, row_num, r'@@ -(\d+),(?:\d+) \+(?:\d+),(?:\d+) @@')
                        manual_command = search_command_group(idx, current_lines, manual_command_suffix)
                        if manual_command:
                            modified_commands.add(manual_command)

            if "aaz" in file_path:
                if aaz_raw_command := search_aaz_raw_command(patch):
                    modified_commands.add(aaz_raw_command)

        commands = list(modified_commands)
        _logger.debug('Modified commands: %s', modified_commands)
        return commands