Skip to content
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

Improve refresh code excerpts when checking codes #9194

Merged
merged 12 commits into from
Oct 26, 2023

Conversation

AlexV525
Copy link
Member

@AlexV525 AlexV525 commented Aug 5, 2023

Detecting code excerpts during checking codes would not tell what codes are refreshed during the check. This PR adds git diff result to tell the difference.

This was inspired during our sync work and implemented in cfug/flutter.cn#1341.

Presubmit checklist

@parlough parlough self-assigned this Aug 9, 2023
@github-actions
Copy link

github-actions bot commented Aug 9, 2023

Visit the preview URL for this PR (updated for commit a157999):

https://flutter-docs-prod--pr9194-feat-improve-refresh-tupn2fio.web.app

(expires Thu, 02 Nov 2023 09:44:01 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: d5ba327eec813901cac8396c4f458b02288624ab

@AlexV525
Copy link
Member Author

AlexV525 commented Aug 17, 2023

@parlough WDYT about this one? We can also update the code_excerpt_updater tool to output changes. But git diff might be more visual.

@parlough
Copy link
Member

parlough commented Aug 18, 2023

Sorry that I haven't taken a look at this yet. I'm working through a long list of reviews and other work.

Without taking a look, adding the support into the tool itself sounds more flexible, but using git diff might be a good solution for now. Thanks for working on this and I'll make sure to take a look as soon as I can :D

@atsansone atsansone added the review.tech Awaiting Technical Review label Aug 26, 2023
@AlexV525
Copy link
Member Author

ping @parlough

AlexV525 added a commit that referenced this pull request Sep 17, 2023
@parlough
Copy link
Member

parlough commented Sep 19, 2023

Sorry again about the delay...

I don't want to land this until #9416 or a similar fix for dart and flutter being inaccessible in the container lands, but I think it may be better to just add the functionality to the code excerpt updater. It has all the information it needs, just needs a flag and to print them out.

@AlexV525
Copy link
Member Author

Sounds fair. I'll see if I can manage to make a request this week for the tool.

@AlexV525
Copy link
Member Author

AlexV525 commented Sep 23, 2023

Rethink about the diff, there is no proper way (for Dart officials) to diff changes between string content in Dart. The updater only updates files regardless of changes. So it might be better to use git diff as a solution.

Copy link
Member

@parlough parlough left a comment

Choose a reason for hiding this comment

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

Sorry about the delay @AlexV525!

You're right that using git diff will be much easier and provide better details.

One suggestion and a question, otherwise looks good to me.

) || (
git --no-pager diff
Copy link
Member

Choose a reason for hiding this comment

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

Won't this only show the diff if there is an error? I believe if all excerpts were successfully refreshed, it won't result an error, so the diff won't be shown.

Maybe this could be moved directly below the git reset? It's probably fine if it always runs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Won't this only show the diff if there is an error? I believe if all excerpts were successfully refreshed, it won't result an error, so the diff won't be shown.

IIRC, from actual tests, refreshes will throw exceptions if there are codes been refreshed and return 0 if no codes have been refreshed.

If "successfully refreshed" means there are some changes during the refresh and the process ends properly, that is a misunderstanding.

Copy link
Member

@parlough parlough Oct 23, 2023

Choose a reason for hiding this comment

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

I tried it out and the diff doesn't seem to run when excerpts were refreshed. I guess that's because executing the refresh script isn't the last executed command in the subshell.

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 took another look of your suggestion, if all excerpts were refreshed, why the diff is required? The diff flow is only meant to help users to identify not refreshed files.

@@ -42,9 +42,14 @@ flutter --version
if [[ $REFRESH ]]; then
echo "=> Refreshing code excerpts..."
(
commitHash=$(git reflog -n1 --format='%h')
Copy link
Member

Choose a reason for hiding this comment

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

Could you put this new behavior under a new flag, like --refresh-diff and then specify that in test.sh? So that those running this locally can opt in to the behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we opt-in? IMO it should at least opt-out. This is helpful whether we test locally or remotely.

Copy link
Member

Choose a reason for hiding this comment

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

That's fine too. It would just be nice to have some way to disable it.

@parlough parlough assigned AlexV525 and unassigned parlough Oct 22, 2023
@parlough parlough added review.await-update Awaiting Updates after Edits and removed review.tech Awaiting Technical Review labels Oct 22, 2023
@AlexV525
Copy link
Member Author

AlexV525 commented Oct 26, 2023

Guys, I don't really like merging from the main branch too often. 😄 It'll somehow affect my acknowledgment of my branchs' status. It can be outdated, but without conflicts.

@domesticmouse
Copy link
Contributor

Guys, I don't really like merging from the main branch too often. 😄 It'll somehow affect my acknowledgment of my branchs' status. It can be outdated, but without conflicts.

Keeping PRs up to date enables easier reviewing as the delta is more accurate

@parlough parlough removed the review.await-update Awaiting Updates after Edits label Oct 26, 2023
Copy link
Member

@parlough parlough left a comment

Choose a reason for hiding this comment

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

I think let's try this out then and see in what situations it helps. We can always expand when/where the diff functionality runs in the future.

Thanks for this Alex and again sorry about the wait.

@parlough parlough merged commit e11bcec into main Oct 26, 2023
9 checks passed
@parlough parlough deleted the feat/improve-refresh-code-excerpts branch October 26, 2023 14:26
atsansone added a commit to atsansone/website that referenced this pull request Nov 14, 2023
Detecting code excerpts during checking codes would not tell what codes
are refreshed during the check. This PR adds `git diff` result to tell
the difference.

This was inspired during our sync work and implemented in
cfug/flutter.cn#1341.

---------

Co-authored-by: Anthony Sansone <[email protected]>
Co-authored-by: Parker Lougheed <[email protected]>
Co-authored-by: Brett Morgan <[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.

4 participants