Repository navigation
Conversation
1. Edge cases not yet handled. 2. Currently only fetches the next release from the sequence and adds the compare link. 3. For the last tag on any page, uses fetchDom to retrieve the next page and extracts the tag from it.
Now, If there are multiple tags on the same commit, we traverse all the commits present on the single page and select the next commit on which different tag is present. Still not handling the case of namespaced tags.
The compare link is generated as follows 1. We find a commit having diffrent commit hash. 2. Once such a commit is found, we check the namespace. If namespaces are same, we use that tag as the previous tag else we try to look further for tag of same namespace. 3. If tag having same namespace is not found on the current page, we use the next commit having different hash. 4. For the last tag on the page, we fetch the next page and follow the same process as above.
|
@bfred-it @sindresorhus Can you please take a look? Thanks! |
There was a problem hiding this comment.
The code is lengthy, consider reducing repetition where possible and skip conditions.
For example:
getCommitIdSelectorandgetTagSelectorcan be skipped if you just usecommitAnchorSelectorandtagAnchorSelectorrespectively? This lets you skip a lot of code and evenisReleasesListPageandisTagsListPagethemselves- the code after
allTagsAnchorandnextPageAllTagsAnchoris nearly identical and can probably be merged.
Generally, instead of creating multiple large code paths (if (){20 lines of code} else {20 lines of code}), try to make standardize the input content. e.g.
for each link on the page (whether it’s one or 20)
compareLink = findNextLink() || findNextLink(memoizedFetchNextPage())
add compareLink next to title
end for
findNextLink() {
if tag has prefix
return query(href ^= prefix)
end if
return query(:not(href ^= prefix))
}Also always use for-of and not a regular for
I'm confident this code can be at least halved :)
I think this article improved my code: https://medium.com/@bartobri/applying-the-linus-tarvolds-good-taste-coding-requirement-99749f37684a
Position: I was expecting this link to be on the commit | zip | tar.gz line and something more clear than ... (I didn't even see the link at first, that ... is generally used to expand the content)
1. Simplified the regex 2. Simplified the tag and commit selectors and removed their unnecessary methods 3. Used the GitHub's diff icon for displaying comparison link 4. Better position for compare link
1. Removed conditional checks before looking for previous tags. All tags are now treated equally whether they are on releases, tag listing or single tag page. 2. Use the single loop to go through the tags irrespective of their index. It also improved the probability of finding the previous tag to compare as we now look into the next page for all the tags.
Done. Simplified the commit id and tag selectors. Also, removed the checks for
Now, Appending the next page tags into the same array and iterating only once. Check for the last tag is also removed.
Here, I need an index of the item so that I can start looking for the tags to match just after that index. You can take a look from Line no 36 and Line no 62.
Initially, I had chosen the same. The same line as commit | zip | tar.gz and for the releases just below the commit hash. (As displayed in the screenshot) But there was some miscommunication due to #966 (comment) and I put the link on |
|
@bfred-it Please take a look at new changes and suggest me if anything still needs to be changed. :) |
…nd commit details
|
Using your suggested approach as for edge case (5c0d57f) my approach silently failed but your approach threw an error which I really liked which led me to realize what mistake I was making. Also in your suggested approach, we only need to iterate only once to extract tag and commit details. (Removed the big comment which now I think is unnecessary.) Let me know if any more changes are needed. Thanks :) |
fregante
left a comment
There was a problem hiding this comment.
Thank you and sorry for all the reviews ❤️
Haha...No need for sorry. I learned a lot through your and Sindre's hardcore reviews. Most of the time I (or any new person) is focused on making something to work and we forget some scenarios or make some silly mistakes. That's where you guys come into the picture. Just making something to work is not enough. I really appreciate your and Sindre's attitude towards perfectness. :) |
fregante
left a comment
There was a problem hiding this comment.
Also, perhaps this should use tiny-version-compare to ensure that the tag we're comparing to is actually lower than the current one.
For example on: https://github.com/tensorflow/tensorflow/releases
The tag right after v1.12.1 is TensorFlow 2.0.0-alpha0 and the generated link shouldn't be:
tensorflow/tensorflow@v2.0.0-alpha0...v1.12.1
but it should compare it against v1.12.0, further down the page
Yep, you are right. I am aware of this limitation and have already mentioned it in a description. I didn't look for any packages (pure out of laziness maybe) 😅. Thanks for the |
`.release-main-section .commit` works on tags in releases list, whether open or collapsed, avoiding the "dummy release" uncollapser element because that doesn't include a `.commit` element. Tested on https://github.com/facebook/react/releases?after=v16.7.0
|
Hallelujah! Finally we merged it. Thanks for this feature! |
|
Also, I noticed a behavior with e.g. On https://github.com/flutter/flutter/releases?after=v1.5.1 releases page. It should compare |



Should fix #966.
I tried to use the API but I couldn't find a way to fetch details of next and previous tags and fetching all tags at once wasn't feasible. (See discussion #966)
I've taken the following approach.
First, I've extracted all tags, commit ids of those tags.
Now, iterating over each tag, I see if the next tag has the different commit id. (Given the fact that we can have multiple tags on the same commit id).
If the next tag has different commit id, then I further check whether the tags are namespaced or not. If the namespace is the same then pick that tag for comparison.
If the next tag has same commit id then that tag is skipped and we check remaining tags.
For the last tag, I fetch the next page using
fetchDomand perform the same steps as mentioned above. If a tag to compare is not found on the next page then we skip the tag.Tested it on the following (and many other) repos.
The feature works on the following pages:
Limitations:
Namespaced tags are only checked within the single page to find it's previous tag. Update: Now we check on the next page, too.For the last tag on the page, we only check on the next page to find the previous tag.Update: For all the tags on any page, we also check the next page for finding its previous tag.The tags are not semantically compared. But we can easily implement it.
PS: Please suggest a better way (if you have) to solve this issue. I would be more than happy to implement it. :)