fix: Direct dependency may upgraded to prerelease version even if pinned to stable #4659
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
fixes #4660
Summary
This PR fixes an issue where
dependency_servicesreportcommand could select a prerelease version even when the direct dependencies are constrained to stable version under certain conditions.Condition
Running
echo '{"target": "foo"}' | dart run ./bin/dependency_services.dart reportPrevious Result
{ "dependencies": [ { "name": "bar", "version": "1.0.0", "kind": "direct", "source": { "type": "hosted", "description": { "name": "bar", "url": "http://localhost:$PORT", "sha256": "e46cfed05052e950f7ded2b9f1a368b5f3705e1aa79b0ee22e041d62d88156eb" } }, "latest": "2.0.0", "constraint": "1.0.0", "compatible": [], "singleBreaking": [], "multiBreaking": [ { "name": "bar", "version": "2.0.0", "kind": "direct", "source": { "type": "hosted", "description": { "name": "bar", "url": "http://localhost:$PORT", "sha256": "5621ac00a63b36202026258131aa189adac2cc9286196a7f82ee0f66cc9047c3" } }, "constraintBumped": "2.0.0", "constraintWidened": "2.0.0", "constraintBumpedIfNeeded": "2.0.0", "previousVersion": "1.0.0", "previousConstraint": "1.0.0", "previousSource": { "type": "hosted", "description": { "name": "bar", "url": "http://localhost:$PORT", "sha256": "e46cfed05052e950f7ded2b9f1a368b5f3705e1aa79b0ee22e041d62d88156eb" } } }, { "name": "foo", "version": "2.0.0-dev.0", "kind": "direct", "source": { "type": "hosted", "description": { "name": "foo", "url": "http://localhost:$PORT", "sha256": "828c6f8043a74375434d47c4bafc8f47ed3707c9ec9caafe78a2803013fc1412" } }, "constraintBumped": "2.0.0-dev.0", "constraintWidened": "2.0.0-dev.0", "constraintBumpedIfNeeded": "2.0.0-dev.0", "previousVersion": "1.0.0", "previousConstraint": "1.0.0", "previousSource": { "type": "hosted", "description": { "name": "foo", "url": "http://localhost:$PORT", "sha256": "48a4851d3cf26e9152a94d346221669b294a26b4aa5d93290b7b3e63ce41eb3c" } } }, { "name": "baz", "version": "2.0.0", "kind": "transitive", "source": { "type": "hosted", "description": { "name": "baz", "url": "http://localhost:$PORT", "sha256": "5b64d7130324b8591ab1b3c5091b4df7a68528a3493ac67b644e49df7486bd28" } }, "constraintBumped": null, "constraintWidened": null, "constraintBumpedIfNeeded": null, "previousVersion": "1.0.0", "previousConstraint": null, "previousSource": { "type": "hosted", "description": { "name": "baz", "url": "http://localhost:$PORT", "sha256": "a7efc9c78968fdb7a7eed37efa3d53caf8b0eef7921b512f581966733cc9fc46" } } } ] }, { "name": "baz", "version": "1.0.0", "kind": "transitive", "source": { "type": "hosted", "description": { "name": "baz", "url": "http://localhost:$PORT", "sha256": "a7efc9c78968fdb7a7eed37efa3d53caf8b0eef7921b512f581966733cc9fc46" } }, "latest": "2.0.0", "constraint": null, "compatible": [], "singleBreaking": [], "multiBreaking": [] }, { "name": "foo", "version": "1.0.0", "kind": "direct", "source": { "type": "hosted", "description": { "name": "foo", "url": "http://localhost:$PORT", "sha256": "48a4851d3cf26e9152a94d346221669b294a26b4aa5d93290b7b3e63ce41eb3c" } }, "latest": "1.0.0", "constraint": "1.0.0", "compatible": [], "singleBreaking": [], "multiBreaking": [ { "name": "foo", "version": "2.0.0-dev.0", "kind": "direct", "source": { "type": "hosted", "description": { "name": "foo", "url": "http://localhost:$PORT", "sha256": "828c6f8043a74375434d47c4bafc8f47ed3707c9ec9caafe78a2803013fc1412" } }, "constraintBumped": "2.0.0-dev.0", "constraintWidened": "2.0.0-dev.0", "constraintBumpedIfNeeded": "2.0.0-dev.0", "previousVersion": "1.0.0", "previousConstraint": "1.0.0", "previousSource": { "type": "hosted", "description": { "name": "foo", "url": "http://localhost:$PORT", "sha256": "48a4851d3cf26e9152a94d346221669b294a26b4aa5d93290b7b3e63ce41eb3c" } } }, { "name": "bar", "version": "2.0.0", "kind": "direct", "source": { "type": "hosted", "description": { "name": "bar", "url": "http://localhost:$PORT", "sha256": "5621ac00a63b36202026258131aa189adac2cc9286196a7f82ee0f66cc9047c3" } }, "constraintBumped": "2.0.0", "constraintWidened": "2.0.0", "constraintBumpedIfNeeded": "2.0.0", "previousVersion": "1.0.0", "previousConstraint": "1.0.0", "previousSource": { "type": "hosted", "description": { "name": "bar", "url": "http://localhost:$PORT", "sha256": "e46cfed05052e950f7ded2b9f1a368b5f3705e1aa79b0ee22e041d62d88156eb" } } }, { "name": "baz", "version": "2.0.0", "kind": "transitive", "source": { "type": "hosted", "description": { "name": "baz", "url": "http://localhost:$PORT", "sha256": "5b64d7130324b8591ab1b3c5091b4df7a68528a3493ac67b644e49df7486bd28" } }, "constraintBumped": null, "constraintWidened": null, "constraintBumpedIfNeeded": null, "previousVersion": "1.0.0", "previousConstraint": null, "previousSource": { "type": "hosted", "description": { "name": "baz", "url": "http://localhost:$PORT", "sha256": "a7efc9c78968fdb7a7eed37efa3d53caf8b0eef7921b512f581966733cc9fc46" } } } ] } ] }New result
{ "dependencies": [ { "name": "bar", "version": "1.0.0", "kind": "direct", "source": { "type": "hosted", "description": { "name": "bar", "url": "http://localhost:$PORT", "sha256": "e46cfed05052e950f7ded2b9f1a368b5f3705e1aa79b0ee22e041d62d88156eb" } }, "latest": "2.0.0", "constraint": "1.0.0", "compatible": [], "singleBreaking": [], "multiBreaking": [] }, { "name": "baz", "version": "1.0.0", "kind": "transitive", "source": { "type": "hosted", "description": { "name": "baz", "url": "http://localhost:$PORT", "sha256": "a7efc9c78968fdb7a7eed37efa3d53caf8b0eef7921b512f581966733cc9fc46" } }, "latest": "2.0.0", "constraint": null, "compatible": [], "singleBreaking": [], "multiBreaking": [] }, { "name": "foo", "version": "1.0.0", "kind": "direct", "source": { "type": "hosted", "description": { "name": "foo", "url": "http://localhost:$PORT", "sha256": "48a4851d3cf26e9152a94d346221669b294a26b4aa5d93290b7b3e63ce41eb3c" } }, "latest": "1.0.0", "constraint": "1.0.0", "compatible": [], "singleBreaking": [], "multiBreaking": [] } ] }Contribution guidelines:
dart format.Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.