-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Include deletions in modified files mask #718
base: main
Are you sure you want to change the base?
Include deletions in modified files mask #718
Conversation
✅ Deploy Preview for onerepo canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As implemented, this will break any command that relies on getFilepaths
and passes them through for operating on.
This is easy to see with eslint. In the oneRepo repository:
- Delete
prettier.config.cjs
- Run
one lint
one lint
┌ Filtering ignored files
└ ✔ 43ms
┌ Lint files
│ ERR Oops! Something went wrong! :(
│ ERR
│ ERR ESLint: 8.57.0
│ ERR
│ ERR No files matching the pattern "prettier.config.cjs" were found.
│ ERR Please check for typing mistakes in the pattern.
└ ✘ 1178ms
■ ✘ Completed with errors 1242ms
I don't think it's a good idea to change how getFilepaths
works, as that would result in a breaking change here. So, in order to preserve that behavior, we should figure out which is best between:
-
Add a flag to
getModifiedFiles
to include deleted or not, eggetModifiedFiles({ includeDeleted: true })
-
OR – create a separate
getModifiedFilesByStatus
that returns an object of the shape:type ModifiedByStatus = { added: Array<string>; copied: Array<string>; modified: Array<string>; deleted: Array<string>; copied: Array<string>; updated: Array<string>; }
This is likely a better long-term solution that would open more possibilities for other plugins and integrations, but may be slightly more work.
Thanks for the info, I also like the second option you mentioned. Ill try to get this updated this week or next week when i have some time. thanks for the feedback! |
@paularmstrong I updated the original getModifiedFiles method to take an additional parameter to specify whether or not to include deletions. But i also implemented the getModifiedFileByStatus method cause it seemed like it might be useful at some point. I updated the tasks command to use the new method but it could just use the existing getModifiedFiles and pass true to the includeDeletions param. Not sure which way you prefer so lmk. Additionally im not really sure how to write good tests around this since it requires git state mgmt, any pointers on how i can write meaningful tests for this? GH Actions were down so i closed and opened the pr to kick them off again since they were stuck |
…eping in case its useful for other users
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Almost there. I'm happy to take over on this if you don't have time.
I think what you've done here is good!
I don't think I would write tests… there's a lot more setup necessary that's not really worth the payoff. |
Thanks for the offer! But I will have time tomorrow to wrap up those changes. |
@jakeleveroni I like what you did – and your changes helped me realize it could be simplified down to reuse the |
Very nice, thats a clever implementation. I like it thanks for the assist! One thing im not quite understanding is the need for the template type |
Nope! It infers it internally. The I need to dig a little bit more to figure out why I had to drop in the |
Problem:
The
git.getModifiedFiles
method does not include removed files.Solution:
The diff filter being used does not include the deletions (D) mask. Changing the diff-filter from
ACMR
toACMRD
includes deleted files in the results of thegit.getModifiedFiles
method.Related issues:
Fixes #706
Checklist:
By opening this pull request, you agree that this submission can be released under the same License that covers the project.