generated from aboutcode-org/skeleton
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support pub package manager #131
Draft
shravankshenoy
wants to merge
2
commits into
aboutcode-org:main
Choose a base branch
from
shravankshenoy:feat/110/support-pub-package-manager
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -385,6 +385,12 @@ def build_value(cls, string): | |||||
return super().build_value(string.lstrip("vV")) | ||||||
|
||||||
|
||||||
class DartVersion(SemverVersion): | ||||||
@classmethod | ||||||
def build_value(cls, string): | ||||||
return super().build_value(string) | ||||||
|
||||||
|
||||||
class GolangVersion(SemverVersion): | ||||||
@classmethod | ||||||
def build_value(cls, string): | ||||||
|
@@ -487,18 +493,22 @@ def __lt__(self, other): | |||||
if not isinstance(other, self.__class__): | ||||||
return NotImplemented | ||||||
# Check if versions have the same base, and `one and only one` of them is a pre-release. | ||||||
if (self.major, self.minor, self.build) == (other.major, other.minor, other.build) and ( | ||||||
self.is_prerelease() != other.is_prerelease() | ||||||
): | ||||||
if (self.major, self.minor, self.build) == ( | ||||||
other.major, | ||||||
other.minor, | ||||||
other.build, | ||||||
) and (self.is_prerelease() != other.is_prerelease()): | ||||||
return self.is_prerelease() | ||||||
return self.value.__lt__(other.value) | ||||||
|
||||||
def __gt__(self, other): | ||||||
if not isinstance(other, self.__class__): | ||||||
return NotImplemented | ||||||
if (self.major, self.minor, self.build) == (other.major, other.minor, other.build) and ( | ||||||
self.is_prerelease() != other.is_prerelease() | ||||||
): | ||||||
if (self.major, self.minor, self.build) == ( | ||||||
other.major, | ||||||
other.minor, | ||||||
other.build, | ||||||
) and (self.is_prerelease() != other.is_prerelease()): | ||||||
return other.is_prerelease() | ||||||
return self.value.__gt__(other.value) | ||||||
|
||||||
|
@@ -702,4 +712,5 @@ def bump(self, index): | |||||
OpensslVersion, | ||||||
LegacyOpensslVersion, | ||||||
AlpineLinuxVersion, | ||||||
DartVersion, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import pytest | ||
|
||
from univers.versions import DartVersion | ||
|
||
|
||
def test_equal(): | ||
assert DartVersion("1.2.3") == DartVersion("1.2.3") | ||
assert DartVersion("1.4.5-dev") == DartVersion("1.4.5-dev") | ||
|
||
# test cases from https://github.com/dart-lang/pub_semver/blob/master/test/version_test.dart | ||
assert DartVersion("01.2.3") == DartVersion("1.2.3") | ||
assert DartVersion("1.02.3") == DartVersion("1.2.3") | ||
assert DartVersion("1.2.03") == DartVersion("1.2.3") | ||
# assert DartVersion("1.2.3-01") == DartVersion("1.2.3-1") | ||
# assert DartVersion("1.2.3+01") == DartVersion("1.2.3+1") | ||
|
||
|
||
def test_compare(): | ||
versions = [ | ||
"1.0.0-alpha", | ||
"1.0.0-alpha.1", | ||
"1.0.0-beta.2", | ||
"1.0.0-beta.11", | ||
"1.0.0-rc.1", | ||
"1.0.0-rc.1+build.1", | ||
"1.0.0", | ||
"1.0.0+0.3.7", | ||
"1.3.7+build", | ||
#'1.3.7+build.2.b8f12d7', | ||
"1.3.7+build.11.e0f985a", | ||
"2.0.0", | ||
"2.1.0", | ||
"2.2.0", | ||
"2.11.0", | ||
"2.11.1", | ||
] | ||
|
||
for i in range(len(versions)): | ||
for j in range(len(versions)): | ||
a = DartVersion(versions[i]) | ||
b = DartVersion(versions[j]) | ||
assert (a < b) == (i < j) | ||
assert (a <= b) == (i <= j) | ||
assert (a > b) == (i > j) | ||
assert (a >= b) == (i >= j) | ||
assert (a == b) == (i == j) | ||
assert (a != b) == (i != j) | ||
|
||
|
||
def test_next_major(): | ||
assert DartVersion(DartVersion("1.2.3").next_major().string) == DartVersion("2.0.0") | ||
assert DartVersion(DartVersion("1.1.4").next_major().string) == DartVersion("2.0.0") | ||
assert DartVersion(DartVersion("2.0.0").next_major().string) == DartVersion("3.0.0") | ||
assert DartVersion(DartVersion("1.2.3-dev").next_major().string) == DartVersion( | ||
"2.0.0" | ||
) | ||
assert DartVersion(DartVersion("2.0.0-dev").next_major().string) == DartVersion( | ||
"2.0.0" | ||
) | ||
assert DartVersion(DartVersion("1.2.3+1").next_major().string) == DartVersion( | ||
"2.0.0" | ||
) | ||
|
||
|
||
def test_next_minor(): | ||
assert DartVersion(DartVersion("1.2.3").next_minor().string) == DartVersion("1.3.0") | ||
assert DartVersion(DartVersion("1.1.4").next_minor().string) == DartVersion("1.2.0") | ||
assert DartVersion(DartVersion("1.3.0").next_minor().string) == DartVersion("1.4.0") | ||
assert DartVersion(DartVersion("1.2.3-dev").next_minor().string) == DartVersion( | ||
"1.3.0" | ||
) | ||
# assert DartVersion(DartVersion("1.3.0-dev").next_minor().string) == DartVersion("1.4.0") | ||
assert DartVersion(DartVersion("1.2.3+1").next_minor().string) == DartVersion( | ||
"1.3.0" | ||
) | ||
|
||
|
||
def test_next_patch(): | ||
assert DartVersion(DartVersion("1.2.3").next_patch().string) == DartVersion("1.2.4") | ||
assert DartVersion(DartVersion("2.0.0").next_patch().string) == DartVersion("2.0.1") | ||
assert DartVersion(DartVersion("1.2.4-dev").next_patch().string) == DartVersion( | ||
"1.2.4" | ||
) | ||
assert DartVersion(DartVersion("1.2.3+2").next_patch().string) == DartVersion( | ||
"1.2.4" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
about_resource: test_pub_version.py | ||
package_url: pkg:pub/[email protected] | ||
download_url: https://github.com/dart-lang/pub_semver/blob/master/test/version_test.dart | ||
homepage_url: https://github.com/dart-lang/pub_semver | ||
license_expression: BSD-3-Clause | ||
notice_file: test_pub_version.py.NOTICE | ||
copyright: Copyright (c) nexB Inc. and others. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Copyright 2014, the Dart project authors. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
* Neither the name of Google LLC nor the names of its | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.