Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/http-client-python"
---

Only copy the legacy code paths required for tests from the baseline sparse-checkout instead of copying the entire `azure/` and `unbranded/` baseline trees.
24 changes: 20 additions & 4 deletions packages/http-client-python/eng/scripts/ci/regenerate-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -716,15 +716,31 @@ export async function prepareBaselineOfGeneratedCode(generatedFolder: string): P
run(`git fetch --depth 1 origin ${branch}`);
run(`git checkout FETCH_HEAD`);

// we don't copy whole generated folder, just the specific subfolders needed for tests
// to verify correct preservation/deletion of files and folders during regeneration,
// to avoid accidentally including any manually edited code that might be in the repo
// and cause confusion when it doesn't get updated during regeneration
const legacyCodePathNeededForTests = [
"azure/authentication-api-key",
"unbranded/authentication-api-key",
"azure/authentication-union",
"azure/generation-subdir",
"azure/generation-subdir2",
"unbranded/generation-subdir",
"unbranded/generation-subdir2",
];

const sourceRoot = join(tempDir, ...sourceSubdir.split("/"));
for (const flavor of ["azure", "unbranded"]) {
const src = join(sourceRoot, flavor);
const dest = join(testsGeneratedDir, flavor);
for (const subPath of legacyCodePathNeededForTests) {
const segments = subPath.split("/");
const src = join(sourceRoot, ...segments);
const dest = join(testsGeneratedDir, ...segments);
if (!existsSync(src)) {
console.warn(pc.yellow(`Baseline folder not found: ${src}`));
continue;
}
console.log(pc.dim(`Copying ${flavor}/ -> ${dest}`));
console.log(pc.dim(`Copying ${subPath} -> ${dest}`));
await mkdir(dirname(dest), { recursive: true });
await cp(src, dest, { recursive: true });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ def _get_etag_role(parameter: dict[str, Any]) -> Optional[str]:
return parameter.get("etagRole")


def _pick_etag_slot(
candidates: list[dict[str, Any]], standard_wire_name: str
) -> Optional[dict[str, Any]]:
def _pick_etag_slot(candidates: list[dict[str, Any]], standard_wire_name: str) -> Optional[dict[str, Any]]:
"""Choose which etag-typed header should be promoted to the etag/match_condition slot.

When more than one etag-typed header is present in an operation, prefer the
Expand Down Expand Up @@ -258,15 +256,14 @@ def _process_operation_etag_headers(
elif role == "ifNoneMatch":
if_none_match_candidates.append(p)

property_if_match, property_if_none_match = _resolve_etag_pair(
if_match_candidates, if_none_match_candidates
)
property_if_match, property_if_none_match = _resolve_etag_pair(if_match_candidates, if_none_match_candidates)

if property_if_match and property_if_none_match:
etag_params = {id(property_if_match), id(property_if_none_match)}
operation["parameters"] = [
item for item in operation["parameters"] if id(item) not in etag_params
] + [property_if_match, property_if_none_match]
operation["parameters"] = [item for item in operation["parameters"] if id(item) not in etag_params] + [
property_if_match,
property_if_none_match,
]
operation["hasEtag"] = True
client["hasEtag"] = True

Expand Down
Loading