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

[VisualStudioMarketplace] Add support to prerelease extensions version (Issue #8207) #8561

Merged
merged 12 commits into from
Oct 25, 2022

Conversation

OronW
Copy link
Contributor

@OronW OronW commented Oct 22, 2022

Added pre-release version support to VScode marketplace service.
Updated response schema.
Updated Tests to include pre-release version.

PR fixing issue #8207

@shields-ci
Copy link

shields-ci commented Oct 22, 2022

Messages
📖 ✨ Thanks for your contribution to Shields, @OronW!

Generated by 🚫 dangerJS against 73b3a63

@OronW OronW changed the title [visualStudioMarketplaceVersion] Add support to prerelease extensions version [visualStudioMarketplaceVersion] Add support to prerelease extensions version (Issue #8207) Oct 22, 2022
Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

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

Thanks for submitting this and including tests. It is looking in pretty good shape to start with and its clear you've worked through the documentation and contributing guidelines. 👍

const { extension } = this.transformExtension({ json })
const version = extension.versions[0].version
const preRelease = 'Microsoft.VisualStudio.Code.PreRelease'
Copy link
Member

Choose a reason for hiding this comment

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

I think the intent here would be a bit clearer if we called this var preReleaseKey or preReleaseTag

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. Fixed.

Comment on lines 47 to 52
const version = includePrereleases
? extension.versions[0].version
: extension.versions.find(
obj => !obj.properties.find(({ key }) => key === preRelease)
).version

Copy link
Member

Choose a reason for hiding this comment

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

There are a couple of problems here.

  1. If there are only pre-releases and no stable releases this will fail because .find() will just return undefined. For this case, we should fall back to showing the latest pre-release if there are no stable releases at all (this is what we normally do for other badges).
  2. This one is a bit more of an edge case: It looks like the deal is pre-releases are indicated by {"key": "Microsoft.VisualStudio.Code.PreRelease", "value": "true"} and stable releases are indicated by complete absence of that object, but I think if we were to encounter a release with {"key": "Microsoft.VisualStudio.Code.PreRelease", "value": "false"} we should also consider that stable (whether or not we currently think this is likely). This code would classify that as a pre-release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your comments.
I've changed the logic a bit so there will not be duplicated code:

  1. I've created a new logic which implements a fallback option.
  2. I now verify the value and not just the presence of the key.

@chris48s chris48s changed the title [visualStudioMarketplaceVersion] Add support to prerelease extensions version (Issue #8207) [VisualStudioMarketplace] Add support to prerelease extensions version (Issue #8207) Oct 24, 2022
@chris48s
Copy link
Member

Minor point: I've edited the PR title so it will run the tests for the whole VSCode Marketplace service family on the next push. This PR modifies the VisualStudioMarketplaceBase class which impacts on all the badges that inherit from it.

@OronW
Copy link
Contributor Author

OronW commented Oct 25, 2022

@chris48s
Thank you for the review and all your comments!

I've updated my code accordingly, and I've added 2 more tests -

  1. For the case where there are only prereleases but the include_prereleases flag is false (fallback to the latest version)
  2. For the case where we might get a "false" value in the prerelease object.

I've also run the entire VisualStudioMarketplace tests locally without issues.

Please let me know if there's anything else :)

Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

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

great first contribution 👍

@chris48s chris48s added service-badge New or updated service badge squash when passing labels Oct 25, 2022
@repo-ranger repo-ranger bot merged commit 252a004 into badges:master Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge New or updated service badge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants