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

Pub: Parse source artifacts for hosted packages #8178

Merged
merged 4 commits into from
Jan 26, 2024

Conversation

mnonnenmacher
Copy link
Member

Add support for source artifacts for hosted packages. See the commit messages for details.

@mnonnenmacher mnonnenmacher requested a review from a team as a code owner January 25, 2024 21:37
@mnonnenmacher mnonnenmacher enabled auto-merge (rebase) January 25, 2024 21:43
Copy link

codecov bot commented Jan 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (46de195) 67.16% compared to head (5f72e01) 67.16%.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8178   +/-   ##
=========================================
  Coverage     67.16%   67.16%           
  Complexity     2049     2049           
=========================================
  Files           357      357           
  Lines         17158    17158           
  Branches       2461     2461           
=========================================
  Hits          11525    11525           
  Misses         4611     4611           
  Partials       1022     1022           
Flag Coverage Δ
funTest-non-docker 33.96% <ø> (ø)
test 36.98% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -532,8 +532,10 @@ class Pub(
var vcs = VcsInfo.EMPTY
var authors = emptySet<String>()

val source = pkgInfoFromLockFile["source"].textValueOrEmpty()
Copy link
Member

Choose a reason for hiding this comment

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

How about doing the same for pkgInfoFromLockFile["description"].textValueOrEmpty(), too, while at it?

Copy link
Member

Choose a reason for hiding this comment

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

On a second thought, maybe just extract val description = pkgInfoFromLockFile["description"] so you can also make use of it in your last commit.

Copy link
Member

@fviernau fviernau Jan 26, 2024

Choose a reason for hiding this comment

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

The reason for not doing so is probably because there is already a var description, see line 529.

Copy link
Member

Choose a reason for hiding this comment

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

Right... but that could easily be solved by using a different variable name, like descriptionNode. Anyway, it was just a proposal.

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 think the whole function needs a refactoring, especially the large when condition. But I don't have time to look deeper into it, esp. since the test data is incomplete, e.g. there are no tests for the host == "git" case, so I only did the small change that was useful for my change.

plugins/package-managers/pub/src/main/kotlin/Pub.kt Outdated Show resolved Hide resolved
@@ -613,8 +626,7 @@ class Pub(
homepageUrl = homepageUrl,
// Pub does not create binary artifacts, therefore use any empty artifact.
binaryArtifact = RemoteArtifact.EMPTY,
// Pub does not create source artifacts, therefore use any empty artifact.
sourceArtifact = RemoteArtifact.EMPTY,
sourceArtifact = sourceArtifact,
Copy link
Member

Choose a reason for hiding this comment

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

What about the original comment here, was it wrong? Is it worth mentioning that in the commit message?

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'm adding support for source artifacts, isn't it obvious that the sentence was wrong?

Copy link
Member

@sschuberth sschuberth Jan 26, 2024

Choose a reason for hiding this comment

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

The comment said "Pub does not create source artifacts" which to me sounded like Pub does not have the concept of source artifacts at all, so I was surprised that you can add support for them.

Copy link
Member Author

Choose a reason for hiding this comment

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

TBH, I have no idea why that sentence was added in the first place, maybe it was wrong all the time, maybe it was correct back in 2019 when it was added.

This is a fixup for e7bdb21.

Signed-off-by: Martin Nonnenmacher <[email protected]>
The expected test results became outdated as these tests are currently
disabled on CI.

Signed-off-by: Martin Nonnenmacher <[email protected]>
Extract the result of reading the package source into a variable to
reduce code duplication.

Signed-off-by: Martin Nonnenmacher <[email protected]>
Parse source artifact information for packages that are hosted in a
package registry like pub.dev from the lockfile.

Signed-off-by: Martin Nonnenmacher <[email protected]>
@mnonnenmacher mnonnenmacher merged commit 232bc19 into main Jan 26, 2024
22 checks passed
@mnonnenmacher mnonnenmacher deleted the pub-source-artifacts branch January 26, 2024 11:16
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.

3 participants