Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
6bb76c53
Commit
6bb76c53
authored
4 years ago
by
Rhys Arkins
Browse files
Options
Downloads
Patches
Plain Diff
fix(cargo): handle * getNewValue
parent
2bc36adc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/versioning/cargo/index.spec.ts
+18
-0
18 additions, 0 deletions
lib/versioning/cargo/index.spec.ts
lib/versioning/cargo/index.ts
+16
-0
16 additions, 0 deletions
lib/versioning/cargo/index.ts
with
34 additions
and
0 deletions
lib/versioning/cargo/index.spec.ts
+
18
−
0
View file @
6bb76c53
...
@@ -103,6 +103,24 @@ describe('semver.isSingleVersion()', () => {
...
@@ -103,6 +103,24 @@ describe('semver.isSingleVersion()', () => {
});
});
});
});
describe
(
'
semver.getNewValue()
'
,
()
=>
{
describe
(
'
semver.getNewValue()
'
,
()
=>
{
it
(
'
returns if empty or *
'
,
()
=>
{
expect
(
semver
.
getNewValue
({
currentValue
:
null
,
rangeStrategy
:
'
bump
'
,
fromVersion
:
'
1.0.0
'
,
toVersion
:
'
1.1.0
'
,
})
).
toEqual
(
null
);
expect
(
semver
.
getNewValue
({
currentValue
:
'
*
'
,
rangeStrategy
:
'
bump
'
,
fromVersion
:
'
1.0.0
'
,
toVersion
:
'
1.1.0
'
,
})
).
toEqual
(
'
*
'
);
});
it
(
'
bumps equals
'
,
()
=>
{
it
(
'
bumps equals
'
,
()
=>
{
expect
(
expect
(
semver
.
getNewValue
({
semver
.
getNewValue
({
...
...
This diff is collapsed.
Click to expand it.
lib/versioning/cargo/index.ts
+
16
−
0
View file @
6bb76c53
import
{
api
as
npm
}
from
'
../npm
'
;
import
{
api
as
npm
}
from
'
../npm
'
;
import
{
VersioningApi
,
NewValueConfig
}
from
'
../common
'
;
import
{
VersioningApi
,
NewValueConfig
}
from
'
../common
'
;
import
{
logger
}
from
'
../../logger
'
;
export
const
id
=
'
cargo
'
;
export
const
id
=
'
cargo
'
;
export
const
displayName
=
'
Cargo
'
;
export
const
displayName
=
'
Cargo
'
;
...
@@ -33,6 +34,10 @@ function notEmpty(s: string): boolean {
...
@@ -33,6 +34,10 @@ function notEmpty(s: string): boolean {
}
}
function
npm2cargo
(
input
:
string
):
string
{
function
npm2cargo
(
input
:
string
):
string
{
// istanbul ignore if
if
(
!
input
)
{
return
input
;
}
// Note: this doesn't remove the ^
// Note: this doesn't remove the ^
const
res
=
input
const
res
=
input
.
split
(
'
'
)
.
split
(
'
'
)
...
@@ -73,6 +78,9 @@ function getNewValue({
...
@@ -73,6 +78,9 @@ function getNewValue({
fromVersion
,
fromVersion
,
toVersion
,
toVersion
,
}:
NewValueConfig
):
string
{
}:
NewValueConfig
):
string
{
if
(
!
currentValue
||
currentValue
===
'
*
'
)
{
return
currentValue
;
}
if
(
rangeStrategy
===
'
pin
'
||
isSingleVersion
(
currentValue
))
{
if
(
rangeStrategy
===
'
pin
'
||
isSingleVersion
(
currentValue
))
{
let
res
=
'
=
'
;
let
res
=
'
=
'
;
if
(
currentValue
.
startsWith
(
'
=
'
))
{
if
(
currentValue
.
startsWith
(
'
=
'
))
{
...
@@ -88,6 +96,14 @@ function getNewValue({
...
@@ -88,6 +96,14 @@ function getNewValue({
toVersion
,
toVersion
,
});
});
let
newCargo
=
npm2cargo
(
newSemver
);
let
newCargo
=
npm2cargo
(
newSemver
);
// istanbul ignore if
if
(
!
newCargo
)
{
logger
.
info
(
{
currentValue
,
newSemver
},
'
Could not get cargo version from semver
'
);
return
currentValue
;
}
// Try to reverse any caret we added
// Try to reverse any caret we added
if
(
newCargo
.
startsWith
(
'
^
'
)
&&
!
currentValue
.
startsWith
(
'
^
'
))
{
if
(
newCargo
.
startsWith
(
'
^
'
)
&&
!
currentValue
.
startsWith
(
'
^
'
))
{
newCargo
=
newCargo
.
substring
(
1
);
newCargo
=
newCargo
.
substring
(
1
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment