Skip to content

File Tree Diff: allow users to ignore files #11977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 10, 2025

Conversation

humitos
Copy link
Member

@humitos humitos commented Feb 5, 2025

Add a field to allow users to tell us what files should be ignored when comparing versions. This is going to be used by the front-end to don't expose these files in the list of added/modified/deleted files.

Peek.2025-02-05.14-26.webm

Closes #11694

Add a field to allow users to tell us what files should be ignored when
comparing versions. This is going to be used by the front-end to don't expose
these files in the list of added/modified/deleted files.

Closes #11694
@humitos humitos requested a review from a team as a code owner February 5, 2025 12:36
@humitos humitos requested a review from stsewd February 5, 2025 12:36
humitos added a commit to readthedocs/ext-theme that referenced this pull request Feb 5, 2025
We don't expose it to all the users yet, but we want to expose it for those that
we already enabled it on the Django Admin.

Requires readthedocs/readthedocs.org#11977
humitos added a commit to readthedocs/addons that referenced this pull request Feb 5, 2025
Filter the added/modified list of files to filter our "ignored files" coming
from the API response.

Requires readthedocs/readthedocs.org#11977
@humitos
Copy link
Member Author

humitos commented Feb 5, 2025

I still need to write some tests for this.

@humitos
Copy link
Member Author

humitos commented Feb 6, 2025

I updated this PR with all the feedback I received (strip lines and use fnmatch in the server). It should be ready for a re-review.

Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

Would be good to get this in next deploy 👍

Comment on lines +717 to +718
"filetreediff_enabled": _("Enabled"),
"filetreediff_ignored_files": _("Ignored files"),
Copy link
Member

Choose a reason for hiding this comment

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

All these labels should be in the model itself, not just in the form.

Copy link
Member Author

Choose a reason for hiding this comment

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

What we would need to use there, verbose_name?

Copy link
Member

Choose a reason for hiding this comment

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

yeah

Copy link
Member Author

Choose a reason for hiding this comment

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

👍🏼 -- I created an issue at #11986

"""Convert a text area into a list of items (one per line)."""
if not value:
return []
return [line.strip() for line in value.splitlines()]
Copy link
Member

Choose a reason for hiding this comment

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

This should probably filter out empty lines. Maybe worth doing this at the model level.

We should also normalize patterns to how the filenames are matched (e.g, if they start or not with a /). I think we do something like this for search.

Copy link
Member Author

@humitos humitos Feb 10, 2025

Choose a reason for hiding this comment

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

This should probably filter out empty lines. Maybe worth doing this at the model level.

Done. I pushed a commit to ignore empty lines.

We should also normalize patterns to how the filenames are matched (e.g, if they start or not with a /). I think we do something like this for search.

I followed the pattern we already have on filetreediff. Currently, the matches start without a / as shown in the UI (the backend saves the filenames in that way as well --we are showing it as it is in the db)

Screenshot_2025-02-10_09-59-48

I like this approach because using starting files with / could be confused with language and version, since people may think it's the full absolute path. For the example shown in the image, the user needs to write commercial/privacy-level.html, or commercial/* or similar ones.

Copy link
Member

Choose a reason for hiding this comment

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

I meant that whatever we choose, we should normalize the paths to match that, e.g, if the user enters /path as a pattern, we should convert that to path, otherwise /path won't match anything.

Copy link
Member Author

Choose a reason for hiding this comment

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

I opened #11987 for that.

@humitos humitos enabled auto-merge (squash) February 10, 2025 09:17
@humitos humitos merged commit 2859ec8 into main Feb 10, 2025
5 checks passed
@humitos humitos deleted the humitos/filetreediff-ignored-diff branch February 10, 2025 09:29
humitos added a commit that referenced this pull request Feb 10, 2025
humitos added a commit that referenced this pull request Feb 11, 2025
Discussion

#11977 (comment)

---------

Co-authored-by: Santos Gallegos <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File tree diff: allow ignoring files
3 participants