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
94695548
Commit
94695548
authored
5 years ago
by
Rhys Arkins
Browse files
Options
Downloads
Patches
Plain Diff
refactor(cocoapods): use autoReplace
parent
0ab9de42
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/manager/cocoapods/index.ts
+0
-1
0 additions, 1 deletion
lib/manager/cocoapods/index.ts
lib/manager/cocoapods/update.spec.ts
+0
-55
0 additions, 55 deletions
lib/manager/cocoapods/update.spec.ts
lib/manager/cocoapods/update.ts
+0
-49
0 additions, 49 deletions
lib/manager/cocoapods/update.ts
with
0 additions
and
105 deletions
lib/manager/cocoapods/index.ts
+
0
−
1
View file @
94695548
import
*
as
rubyVersioning
from
'
../../versioning/ruby
'
;
export
{
extractPackageFile
}
from
'
./extract
'
;
export
{
updateDependency
}
from
'
./update
'
;
export
{
updateArtifacts
}
from
'
./artifacts
'
;
export
const
defaultConfig
=
{
...
...
This diff is collapsed.
Click to expand it.
lib/manager/cocoapods/update.spec.ts
deleted
100644 → 0
+
0
−
55
View file @
0ab9de42
import
fs
from
'
fs-extra
'
;
import
path
from
'
path
'
;
import
{
updateDependency
}
from
'
.
'
;
const
fileContent
=
fs
.
readFileSync
(
path
.
resolve
(
__dirname
,
'
./__fixtures__/Podfile.simple
'
),
'
utf-8
'
);
describe
(
'
lib/manager/cocoapods/update
'
,
()
=>
{
describe
(
'
updateDependency
'
,
()
=>
{
it
(
'
handles undefined lines
'
,
()
=>
{
const
upgrade
=
{
depName
:
'
b
'
,
managerData
:
{
lineNumber
:
999999999
},
currentValue
:
'
1.2.3
'
,
newValue
:
'
2.0.0
'
,
};
const
res
=
updateDependency
({
fileContent
,
upgrade
});
expect
(
res
).
toBeNull
();
});
it
(
'
replaces existing value
'
,
()
=>
{
const
upgrade
=
{
depName
:
'
b
'
,
managerData
:
{
lineNumber
:
4
},
currentValue
:
'
1.2.3
'
,
newValue
:
'
2.0.0
'
,
};
const
res
=
updateDependency
({
fileContent
,
upgrade
});
expect
(
res
).
not
.
toEqual
(
fileContent
);
expect
(
res
.
includes
(
upgrade
.
newValue
)).
toBe
(
true
);
});
it
(
'
returns same content
'
,
()
=>
{
const
upgrade
=
{
depName
:
'
b
'
,
managerData
:
{
lineNumber
:
4
},
currentValue
:
'
1.2.3
'
,
newValue
:
'
1.2.3
'
,
};
const
res
=
updateDependency
({
fileContent
,
upgrade
});
expect
(
res
).
toEqual
(
fileContent
);
expect
(
res
).
toBe
(
fileContent
);
});
it
(
'
returns null
'
,
()
=>
{
const
upgrade
=
{
depName
:
'
b
'
,
managerData
:
{
lineNumber
:
0
},
currentValue
:
'
1.2.3
'
,
newValue
:
'
2.0.0
'
,
};
const
res
=
updateDependency
({
fileContent
,
upgrade
});
expect
(
res
).
toBeNull
();
});
});
});
This diff is collapsed.
Click to expand it.
lib/manager/cocoapods/update.ts
deleted
100644 → 0
+
0
−
49
View file @
0ab9de42
import
{
logger
}
from
'
../../logger
'
;
import
{
UpdateDependencyConfig
}
from
'
../common
'
;
import
{
parseLine
}
from
'
./extract
'
;
function
lineContainsDep
(
line
:
string
,
dep
:
string
):
boolean
{
const
{
depName
}
=
parseLine
(
line
);
return
dep
===
depName
;
}
export
function
updateDependency
({
fileContent
,
upgrade
,
}:
UpdateDependencyConfig
):
string
|
null
{
const
{
currentValue
,
managerData
,
depName
,
newValue
}
=
upgrade
;
// istanbul ignore if
if
(
!
currentValue
||
!
managerData
||
!
depName
)
{
logger
.
warn
(
'
Cocoapods: invalid upgrade object
'
);
return
null
;
}
logger
.
debug
(
`cocoapods.updateDependency:
${
newValue
}
`
);
const
lines
=
fileContent
.
split
(
'
\n
'
);
const
lineToChange
=
lines
[
managerData
.
lineNumber
];
if
(
!
lineToChange
)
{
logger
.
warn
(
{
fileContent
,
depName
,
currentValue
,
newValue
},
'
Undefined cocoapods lineToChange
'
);
return
null
;
}
if
(
!
lineContainsDep
(
lineToChange
,
depName
))
{
return
null
;
}
const
regex
=
new
RegExp
(
`(['"])
${
currentValue
.
replace
(
'
.
'
,
'
\\
.
'
)}
\\
1`
);
const
newLine
=
lineToChange
.
replace
(
regex
,
`$1
${
newValue
}
$1`
);
if
(
newLine
===
lineToChange
)
{
logger
.
debug
(
'
No changes necessary
'
);
return
fileContent
;
}
lines
[
managerData
.
lineNumber
]
=
newLine
;
return
lines
.
join
(
'
\n
'
);
}
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