Skip to content

Conversation

@frankharkins
Copy link
Member

@frankharkins frankharkins commented Dec 12, 2025

Closes #4366

Comment on lines +133 to +134
if "api" in contents:
ignores.append("api")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to no matter what ignore /api/, specifically with the main.yml workflow. Also, I would check for /api/ and not api because we have legit guides like primitives-rest-api

Copy link
Member Author

@frankharkins frankharkins Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does do that: contents is a list of directory entries (e.g. ["api", "index.mdx", ... ]), so this has the effect of ignoring all paths matching /api/ and would not match primitives-rest-api. I think the confusion is because the interface of copytree's ignore is a bit unusual, I'll try to clarify in the comments.

lines = Path(".github/outputs/changed-content-files.txt").read_text().split("\n")
changed_content_files = set(line for line in lines if line != "")
except FileNotFoundError:
changed_content_files: set[str] = set()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe log (with logger)?

Copy link
Collaborator

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This overall looks great

Comment on lines +162 to +163
# Finally, continue traversing if the directory contains one of our
# changed files.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment makes me think that we will include all of the files in a directory if at least one is changed, i.e. sibling files. I don't think that's what the code is doing though. Maybe this?

Suggested change
# Finally, continue traversing if the directory contains one of our
# changed files.
# Finally, include files that were directly changed.


def _copy_local_content(root_dir: Path, changed_files: set[str]) -> None:

def ignore_contents(dir: str, contents: list[str]) -> list[str]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Often I'm a fan of inlined functions, but here I think it makes the code more confusing than necessary. You aren't using anything from the outer closure, and the helper function is quite verbose. I recommend moving it to a standalone function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

PR preview only has changed files

2 participants