-
Notifications
You must be signed in to change notification settings - Fork 383
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
feat: Add the stdlib_diff tool to compare gno and go standard libraries #2869
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
@thehowl I took a look of this, the current status: 4 and 5 are fixed on eaf6a87
|
|
Removed the "review team" label because this is already reviewed by thehowl. |
…tion is the standard gno library
eaf6a87
to
777a759
Compare
Hey thanks a lot again for the review 👍 @thehowl . For 1 I added the line numbers and they are not selectable 2- Thanks a lot for this library tip, I was actually taking a lot of time trying to figure this line diff algorithm but It was pretty straightforward with the one you recommended. The only downside is that the library just return the part of the file that have some changes, so to print the entire file I needed to add some specific code to accomplish it. 3- subdirectories are listed on the index, if a library have subdirectories it will appear like a toggle list. I think there is still some improvements to do to the overall code, Just wanted to make sure this is the behaviour we'll like before doing some cleaning . Thanks |
I suggest you not to rebase your PRs, but instead to merge in master; it makes my work when reviewing easier. And possibly yours as well, in managing conflicts. (There are none here I think, but this is good general guidance) |
How are you running the thing? I'm running with |
Sorry about that I'll keep it on mind
I run it like this and for me it's working fine: go run . -src /opt/homebrew/Cellar/go/1.23.0/libexec/src -dst ../../gnovm/stdlibs -out ~/gnoreport/
2024/10/05 23:55:08 Building report...
2024/10/05 23:55:09 Report generation done! |
@thehowl |
Okay, figured it out. My The performance is satisfactory now. Thank you. I have a bunch of comments to make on some of the looks. Mostly things about UX / confusing more than design wise, just to make sure this thing is decently usable. Tell me if you want 'em your way, or I can wait if you already have ideas.
|
@thehowl Thanks again for this new round of review :)
Yep I'm using unified diff but seems like it only keeps the lines that have some differences, so entire parts of the file could be omited edits := myers.ComputeEdits(span.URIFromPath(f.Src), f.srcContent, f.dstContent)
unified := gotextdiff.ToUnified(f.Src, f.Dst, f.srcContent, edits) Some sort of what github does(you can only see from line 8-12: |
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 some more improvements overall, but I think with these few changes we're good to merge and iterate. Thanks, and sorry for the delay in the review!
misc/stdlib_diff/README.md
Outdated
@@ -0,0 +1,31 @@ | |||
# Stdlibs_diff |
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.
# Stdlibs_diff | |
# stdlib_diff |
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.
fixed on 2ff4f9e
misc/stdlib_diff/README.md
Outdated
@@ -0,0 +1,31 @@ | |||
# Stdlibs_diff | |||
|
|||
Stdlibs_diff is a tool that generates an html report indicating differences between gno standard libraries and go standrad libraries |
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.
Stdlibs_diff is a tool that generates an html report indicating differences between gno standard libraries and go standrad libraries | |
stdlib_diff is a tool that generates an html report indicating differences between gno standard libraries and go standrad libraries |
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.
fixed on 2ff4f9e
misc/stdlib_diff/README.md
Outdated
| src | Directory containing packages that will be compared to destination | None | | ||
| dst | Directory containing packages; used to compare src packages | None | | ||
| out | Directory where the report will be created | None | | ||
| src_is_gno | Indicates if the src parameters is the gno standard library | false | |
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.
Though, IMO, this shouldn't really matter: flipping src and dst should yield mostly the same results, with the green/red lines swapped.
The result is that we should also show, in green, at the package level, libraries like "std" and "crypto/chacha20": they can be an aid to quickly illustrate what's new compared to go.
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.
I removed the flag src_is_gno and I changed the way to obtain what each directory is suppose to contain gno or go files. on 2ff4f9e
misc/stdlib_diff/report.go
Outdated
// getRealPath will check if the directory is a symbolic link and resolve if path before returning it | ||
func getRealPath(path string) (string, error) { | ||
info, err := os.Lstat(path) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
if info.Mode()&fs.ModeSymlink != 0 { | ||
// File is symbolic link, no need to resolve | ||
link, err := os.Readlink(path) | ||
if err != nil { | ||
return "", fmt.Errorf("can't resolve symbolic link: %w", err) | ||
} | ||
return link, nil | ||
} | ||
|
||
return path, nil | ||
} |
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.
This doesn't actually work, because it doesn't understand symlinks in intermediate parts of the path: you're looking for filepath.EvalSymlinks
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.
changed to use filepath.EvalSymlinks on 2ff4f9e
} | ||
return "", err | ||
} | ||
return strings.ReplaceAll(string(data), "\t", " "), nil |
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.
Why?
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.
This is my way to convert the tabs to 4 spaces. is is working maybe is not the best way ?
Maybe I misunderstood
1- Formatting is still very funky. Use CSS to render tabs correctly; they should render as 4 spaces.
This line is doing the spaces to have the width equivalent of 4 spaces but when selected it is still a tab. I thought we had to convert it to real 4 spaces.
p {
white-space-collapse: preserve;
margin: 0;
font-size: 1rem;
font-weight: 400;
tab-size: 4;
}
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 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.
fixed on 2ff4f9e
btw, can you modify the gh-pages workflow? (.github/workflows/gh-pages) so it creates the report automatically on each push. Maybe put the report in the subdir I suggest you also try it out on a fork and link to a sample output, so we can check the workflow works correctly ahead of the merge. |
🛠 PR Checks Summary🔴 Maintainers must be able to edit this pull request (more info) Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🔴 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
@thehowl I followed your recommendations, here is the result :) thanks |
continuing the work started on #1425
thanks FloRichardAloeCorp for the great job on this issue 👍
closes #1310
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description