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

tools: fix incorrect version history order #45728

Merged
merged 1 commit into from
Dec 14, 2022

Conversation

welfoz
Copy link
Contributor

@welfoz welfoz commented Dec 3, 2022

Hi!

This is the first PR of my life 💯
I tried my best 🚀

Please tell me if this fix needs a test or not.

Here is my commit message:
This fixes an error in parseYAML(text), the version sorting coudn't be right as we compared an arrify string (ie. a = ["v18.11, v16.7.0"]) with an array of strings (ie. b = ["v18.07", "v16.7.0"]) in versionSort(a, b).

minVersion(a) couldn't find the minimum version with an arrify string like a = ["v18.11, v16.7.0"].
That's why incorrect version history orders sometimes appeared.

Fixes: #45670

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. tools Issues and PRs related to the tools directory. labels Dec 3, 2022
@welfoz welfoz marked this pull request as ready for review December 3, 2022 19:56
@lpinca
Copy link
Member

lpinca commented Dec 3, 2022

See #45726 (comment).

@welfoz
Copy link
Contributor Author

welfoz commented Dec 3, 2022

See #45726 (comment).

What does this mean? What should I do?

@lpinca
Copy link
Member

lpinca commented Dec 3, 2022

It explains why the order is the one reported in #45670 which is not directly related to the changes done here. These changes might be ok but they do not fully fix the issue.

@welfoz
Copy link
Contributor Author

welfoz commented Dec 4, 2022

It explains why the order is the one reported in #45670 which is not directly related to the changes done here. These changes might be ok but they do not fully fix the issue.

node/doc/api/util.md

Lines 1378 to 1392 in f6052c6

<!-- YAML
added:
- v18.3.0
- v16.17.0
changes:
- version: v18.11.0
pr-url: https://github.com/nodejs/node/pull/44631
description: Add support for default values in input `config`.
- version:
- v18.7.0
- v16.17.0
pr-url: https://github.com/nodejs/node/pull/43459
description: add support for returning detailed parse information
using `tokens` in input `config` and returned properties.
-->



In the example above, before sorting the version part of meta.changes looks like:

 ["v18.11.0", ["v18.7.0", "v16.17.0" ], [ "v18.3.0", "v16.17.0" ]] 

With my commit implemented, the versionSort() function, after the minVersion(), will compare the same string for the last 2 indexes (

 "v16.17.0"

) and return 0. So, the initial order won't change.

image
https://developer.mozilla.org/enUS/docs/Web/JavaScript/Reference/Global_Objects/Array/sort



Last point, in this case, when several similar minimal versions are in the "changes" part and in the added, deprecated or deleted part, the order will remain the same because they are the last ones pushed in the meta.changes array.

node/tools/doc/html.mjs

Lines 344 to 346 in f6052c6

if (added.description) meta.changes.push(added);
if (deprecated.description) meta.changes.push(deprecated);
if (removed.description) meta.changes.push(removed);




When you build the doc, here is the new output:
image

I would be grateful if you could explain me what's missing 😄

@lpinca
Copy link
Member

lpinca commented Dec 4, 2022

This is what happens on the main branch. The original issue refers to the latest v18.x version where the 'v16.17.0' is not present in the added array

node/doc/api/util.md

Lines 1025 to 1037 in 9ca57fa

<!-- YAML
added: v18.3.0
changes:
- version: v18.11.0
pr-url: https://github.com/nodejs/node/pull/44631
description: Add support for default values in input `config`.
- version:
- v18.7.0
- v16.17.0
pr-url: https://github.com/nodejs/node/pull/43459
description: add support for returning detailed parse information
using `tokens` in input `config` and returned properties.
-->

It seems that this commit db5aeed added the 'v16.17.0' version for the changes array but the author forgot to add it in the added array. The commit was then backported to the v18.x branch.

Of course we can manually add the 'v16.17.0' version in the added array of the v18.x-staging branch or wait until a new backported commit will fix the issue but I think we can go further and handle cases like this by moving this line

if (added.description) meta.changes.push(added);

after the meta.changes array is sorted

meta.changes.sort((a, b) => versionSort(a.version, b.version));

The added in version always comes first. There is no need to sort it.

@welfoz
Copy link
Contributor Author

welfoz commented Dec 4, 2022

@lpinca You're right. I didn't see this that way.

I think there is no need to do the same for removed or deprecated versions as we need to move them at the beginning of the meta.changes array.
As they will always be newer versions they will automatically be sorted. If not, we could still push them directly at the beginning with meta.changes.unsift(removed)

tools/doc/html.mjs Outdated Show resolved Hide resolved
tools/doc/html.mjs Outdated Show resolved Hide resolved
tools/doc/html.mjs Outdated Show resolved Hide resolved
@panva panva added the commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. label Dec 4, 2022
@lpinca
Copy link
Member

lpinca commented Dec 4, 2022

Test failures are related but I'm not sure why. This needs to be investigated.

@welfoz
Copy link
Contributor Author

welfoz commented Dec 4, 2022

Test failures are related but I'm not sure why. This needs to be investigated.

I'm investigating in.
The first one is my fault, my commit message doesn't follow the rules of 72 characters / column max.

@lpinca
Copy link
Member

lpinca commented Dec 4, 2022

diff --git a/test/doctool/test-doctool-html.mjs b/test/doctool/test-doctool-html.mjs
index 9323548221..6fbca13185 100644
--- a/test/doctool/test-doctool-html.mjs
+++ b/test/doctool/test-doctool-html.mjs
@@ -79,10 +79,11 @@ const testData = [
       '<div class="api_metadata">' +
       '<details class="changelog"><summary>History</summary>' +
       '<table><tbody><tr><th>Version</th><th>Changes</th></tr>' +
+      '<tr><td>v4.2.0</td><td><p>The <code>error</code> parameter can now be' +
+      'an arrow function.</p></td></tr>' +
       '<tr><td>v5.3.0, v4.2.0</td>' +
       '<td><p><span>Added in: v5.3.0, v4.2.0</span></p></td></tr>' +
-      '<tr><td>v4.2.0</td><td><p>The <code>error</code> parameter can now be' +
-      'an arrow function.</p></td></tr></tbody></table></details></div> ' +
+      '</tbody></table></details></div> ' +
       '<p>Describe <code>Foobar II</code> in more detail here.' +
       '<a href="http://man7.org/linux/man-pages/man1/fg.1.html"><code>fg(1)' +
       '</code></a></p></section><section>' +

This should fix the failing test.

@welfoz
Copy link
Contributor Author

welfoz commented Dec 4, 2022

diff --git a/test/doctool/test-doctool-html.mjs b/test/doctool/test-doctool-html.mjs
index 9323548221..6fbca13185 100644
--- a/test/doctool/test-doctool-html.mjs
+++ b/test/doctool/test-doctool-html.mjs
@@ -79,10 +79,11 @@ const testData = [
       '<div class="api_metadata">' +
       '<details class="changelog"><summary>History</summary>' +
       '<table><tbody><tr><th>Version</th><th>Changes</th></tr>' +
+      '<tr><td>v4.2.0</td><td><p>The <code>error</code> parameter can now be' +
+      'an arrow function.</p></td></tr>' +
       '<tr><td>v5.3.0, v4.2.0</td>' +
       '<td><p><span>Added in: v5.3.0, v4.2.0</span></p></td></tr>' +
-      '<tr><td>v4.2.0</td><td><p>The <code>error</code> parameter can now be' +
-      'an arrow function.</p></td></tr></tbody></table></details></div> ' +
+      '</tbody></table></details></div> ' +
       '<p>Describe <code>Foobar II</code> in more detail here.' +
       '<a href="http://man7.org/linux/man-pages/man1/fg.1.html"><code>fg(1)' +
       '</code></a></p></section><section>' +

This should fix the failing test.

Yes! From what I understand, the test breaks because now we force the added version to be the last one.

image

@welfoz
Copy link
Contributor Author

welfoz commented Dec 4, 2022

I needed to change the first commit message, so I did a rebase, and then a push --force.

@lpinca the test now passed in local!

@welfoz
Copy link
Contributor Author

welfoz commented Dec 5, 2022

image


This command has 1 test failing because of an excessive duration:
image

Does anyone have any idea why this failed?

@welfoz
Copy link
Contributor Author

welfoz commented Dec 11, 2022

@lpinca @panva do you know if it will be merged ?
Tell me if I need to do something else 😄

@panva
Copy link
Member

panva commented Dec 11, 2022

@welfoz I only managed the labels while passing by, so, I don't know 🤷‍♂️.

@panva panva added the review wanted PRs that need reviews. label Dec 11, 2022
@lpinca
Copy link
Member

lpinca commented Dec 12, 2022

@welfoz can you please squash the commits?

@welfoz
Copy link
Contributor Author

welfoz commented Dec 12, 2022

@welfoz can you please squash the commits?

Done! I've fetch the HEAD and squash all the commits :)

@lpinca
Copy link
Member

lpinca commented Dec 12, 2022

Thanks, one last request, can you please replace "Therefore," in commit message with something like "Furthermore, there is". That "Therefore" seems misplaced.

@welfoz
Copy link
Contributor Author

welfoz commented Dec 12, 2022

My bad, this is fixed!

@welfoz
Copy link
Contributor Author

welfoz commented Dec 12, 2022

@lpinca I've changed the commit message again because the "Co-authored-by" part was misplaced.

@lpinca
Copy link
Member

lpinca commented Dec 12, 2022

Now that you are at it, "Futhermore" -> "Furthermore" ;)

@lpinca lpinca removed the commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. label Dec 12, 2022
This fixes an error in parseYAML(text), the version sorting
coudn't be right as we compared an arrify string
(ie. a = ["v18.11, v16.7.0"]) with an array of strings
(ie. b = ["v18.07", "v16.7.0"]) in versionSort(a, b).

minVersion(a) couldn't find the minimum version with an arrify string
like a = ["v18.11, v16.7.0"].
That's why incorrect version history orders sometimes appeared.

Furthermore, no need to sort the added version as it always comes first.
So, it can be the last one to be pushed in the meta.changes array.

Fixes: nodejs#45670

Co-authored-by: Luigi Pinca <[email protected]>
@welfoz
Copy link
Contributor Author

welfoz commented Dec 12, 2022

Now that you are at it, "Futhermore" -> "Furthermore" ;)

I'm now mastering the git rebase -i command haha

@lpinca lpinca added the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 13, 2022
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Dec 13, 2022
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/45728
✔  Done loading data for nodejs/node/pull/45728
----------------------------------- PR info ------------------------------------
Title      tools: fix incorrect version history order (#45728)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     welfoz:fabien -> nodejs:main
Labels     doc, tools, review wanted
Commits    1
 - tools: fix incorrect version history order
Committers 1
 - Fabien MICHEL 
PR-URL: https://github.com/nodejs/node/pull/45728
Fixes: https://github.com/nodejs/node/issues/45670
Reviewed-By: Luigi Pinca 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/45728
Fixes: https://github.com/nodejs/node/issues/45670
Reviewed-By: Luigi Pinca 
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last review:
   ⚠  - tools: fix incorrect version history order
   ℹ  This PR was created on Sat, 03 Dec 2022 19:55:48 GMT
   ✔  Approvals: 1
   ✔  - Luigi Pinca (@lpinca): https://github.com/nodejs/node/pull/45728#pullrequestreview-1203699118
   ✔  Last GitHub CI successful
   ✖  No Jenkins CI runs detected
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/3689291523

@lpinca lpinca added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 13, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 13, 2022
@nodejs-github-bot
Copy link
Collaborator

@lpinca lpinca added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Dec 14, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 14, 2022
@nodejs-github-bot nodejs-github-bot merged commit bfb5ba7 into nodejs:main Dec 14, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in bfb5ba7

targos pushed a commit that referenced this pull request Jan 1, 2023
This fixes an error in parseYAML(text), the version sorting
coudn't be right as we compared an arrify string
(ie. a = ["v18.11, v16.7.0"]) with an array of strings
(ie. b = ["v18.07", "v16.7.0"]) in versionSort(a, b).

minVersion(a) couldn't find the minimum version with an arrify string
like a = ["v18.11, v16.7.0"].
That's why incorrect version history orders sometimes appeared.

Furthermore, no need to sort the added version as it always comes first.
So, it can be the last one to be pushed in the meta.changes array.

Fixes: #45670

Co-authored-by: Luigi Pinca <[email protected]>
PR-URL: #45728
Reviewed-By: Luigi Pinca <[email protected]>
@RafaelGSS RafaelGSS mentioned this pull request Jan 2, 2023
juanarbol pushed a commit that referenced this pull request Jan 26, 2023
This fixes an error in parseYAML(text), the version sorting
coudn't be right as we compared an arrify string
(ie. a = ["v18.11, v16.7.0"]) with an array of strings
(ie. b = ["v18.07", "v16.7.0"]) in versionSort(a, b).

minVersion(a) couldn't find the minimum version with an arrify string
like a = ["v18.11, v16.7.0"].
That's why incorrect version history orders sometimes appeared.

Furthermore, no need to sort the added version as it always comes first.
So, it can be the last one to be pushed in the meta.changes array.

Fixes: #45670

Co-authored-by: Luigi Pinca <[email protected]>
PR-URL: #45728
Reviewed-By: Luigi Pinca <[email protected]>
@juanarbol juanarbol mentioned this pull request Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. review wanted PRs that need reviews. tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[node:util] Incorrect order in util.parseArgs history
4 participants