-
Notifications
You must be signed in to change notification settings - Fork 808
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
Tools: Show warning when using rsync with untracked files #41442
Tools: Show warning when using rsync with untracked files #41442
Conversation
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! |
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.
Seems to work fine. Some comments inline about the warning with --watch
though.
tools/cli/commands/rsync.js
Outdated
@@ -86,6 +104,22 @@ export async function rsyncInit( argv ) { | |||
|
|||
const paths = await rsyncToDest( sourcePluginPath, finalDest ); | |||
|
|||
// Warn but don't fail if file was intentionally not synced. |
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.
Except sometimes being triggered by unsynced file changes is intentional.
jetpack/tools/cli/commands/rsync.js
Line 139 in af2df47
// Also watch the git index for changes to catch `git add`, as that may change which files are synced. |
jetpack/tools/cli/commands/rsync.js
Lines 142 to 143 in af2df47
// Watch `.gitignore` and `.gitattributes` in parent dirs, as they too may change which files are synced. | |
// Here we assume sourcePluginPath is always `projects/plugins/whatever` |
The same could apply to changes in
.gitignore
or .gitattributes
in the plugin dir itself.
Your change here doesn't break it, since it still does the sync, but it does print a potentially confusing message. After a git add
, for example,
building file list ...
543 files to consider
foo.txt
0 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=536/543)
sent 15,131 bytes received 34 bytes 30,330.00 bytes/sec
total size is 2,560,591 speedup is 168.85
Sync was triggered by a change to '../../../.git/index', but it was not synced.
Reason: not tracked by git
Also of note is that eventfile may not be the only file that changed. We debounce the events, so if several files are changed in quick succession only the last one will be seen here. Again, that might be confusing if the last is untracked but earlier ones were tracked.
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.
Except sometimes being triggered by unsynced file changes is intentional.
Also of note is that eventfile may not be the only file that changed. We debounce the events, so if several files are changed in quick succession only the last one will be seen here. Again, that might be confusing if the last is untracked but earlier ones were tracked.
Yes, I alluded to that in the PR body: "It's still good to trigger the sync in these cases, as more than one file might have changed."
I believe the message is technically accurate, but am open to suggestions on how to make it less confusing.
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.
What's the purpose of the warning? If we want to repeat the "these untracked files weren't synced" warning, maybe just do that directly?
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.
There are two parts:
- Highlight untracked files in case someone forgot to
git add
. The user can proceed or abort at this stage. - When a file is changed during
watch
, it might not be synced. Sometimes that's expected, and sometimes it's not.
I think your concern lies solely on the watch
scenario, correct?
We could show a prompt each time (if that's what you mean), but that somewhat defeats the point of a background watch, particularly when it could be something we know about and don't care about.
Aside: In cases when the file is arbitrarily changed in a batch of changes, it's likely that file's event will be debounced and not show the notice anyway, but if it's individually edited, there's a larger chance that the user is trying to get it synced and it's failing.
Two tweaks I can think of while fulfilling the above:
- Put the notices behind the
-v
flag. - Filter out changes to a few hard-coded files (e.g.
../../../.git/index
).
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.
Yes, the watch scenario is what I'm concerned with. And yeah, definitely no prompt, that would defeat the purpose.
One idea I had is to keep a list of untracked files from the last warning, and at each watch-sync warn about any new untracked files that showed up, like "The following new untracked files are not being synced". Although that would miss the case where someone keeps saving the same file because they didn't see an earlier warning. Maybe only print eventfile
if it's in the list of untracked files and there are no new ones?
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.
Discussed this in Slack; there's not one good answer as written. For now I've moved the notices to only show in verbose mode: 2d7cbae
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.
Good enough. 🚢
By design
jetpack rsync
only syncs files that are expected to be in production. This means untracked files are not synced. However, this has caused confusion in the past (e.g. p1737037284874559-slack-CDLH4C1UZ).This PR adds a warning prompt prior to running the rsync:
Also, when
jetpack rsync --watch
is used, it will output a notice if a sync is triggered by a file that will not be synced itself for one of the following reasons:It's still good to trigger the sync in these cases, as more than one file might have changed.
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
Try
jetpack rsync
andjetpack rsync --watch
with various combinations: