Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SmartDataLab
public
applications
renovate
Commits
bccf0997
Unverified
Commit
bccf0997
authored
2 years ago
by
RahulGautamSingh
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor: delete cached configFilename (#20746)
parent
99c697a7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/workers/repository/init/merge.spec.ts
+19
-0
19 additions, 0 deletions
lib/workers/repository/init/merge.spec.ts
lib/workers/repository/init/merge.ts
+12
-1
12 additions, 1 deletion
lib/workers/repository/init/merge.ts
with
31 additions
and
1 deletion
lib/workers/repository/init/merge.spec.ts
+
19
−
0
View file @
bccf0997
...
...
@@ -3,12 +3,16 @@ import {
fs
,
getConfig
,
git
,
logger
,
mocked
,
partial
,
platform
,
}
from
'
../../../../test/util
'
;
import
*
as
_migrateAndValidate
from
'
../../../config/migrate-validate
'
;
import
*
as
_migrate
from
'
../../../config/migration
'
;
import
*
as
repoCache
from
'
../../../util/cache/repository
'
;
import
{
initRepoCache
}
from
'
../../../util/cache/repository/init
'
;
import
type
{
RepoCacheData
}
from
'
../../../util/cache/repository/types
'
;
import
{
checkForRepoConfigError
,
detectRepoFileConfig
,
...
...
@@ -45,6 +49,21 @@ describe('workers/repository/init/merge', () => {
expect
(
await
detectRepoFileConfig
()).
toEqual
({});
});
it
(
'
returns config if not found - uses cache
'
,
async
()
=>
{
jest
.
spyOn
(
repoCache
,
'
getCache
'
)
.
mockReturnValueOnce
(
partial
<
RepoCacheData
>
({
configFileName
:
'
renovate.json
'
})
);
platform
.
getRawFile
.
mockRejectedValueOnce
(
new
Error
());
git
.
getFileList
.
mockResolvedValue
([
'
package.json
'
]);
fs
.
readLocalFile
.
mockResolvedValue
(
'
{}
'
);
expect
(
await
detectRepoFileConfig
()).
toEqual
({});
expect
(
logger
.
logger
.
debug
).
toHaveBeenCalledWith
(
'
Existing config file no longer exists
'
);
});
it
(
'
uses package.json config if found
'
,
async
()
=>
{
git
.
getFileList
.
mockResolvedValue
([
'
package.json
'
]);
const
pJson
=
JSON
.
stringify
({
...
...
This diff is collapsed.
Click to expand it.
lib/workers/repository/init/merge.ts
+
12
−
1
View file @
bccf0997
...
...
@@ -17,6 +17,7 @@ import {
import
{
logger
}
from
'
../../../logger
'
;
import
*
as
npmApi
from
'
../../../modules/datasource/npm
'
;
import
{
platform
}
from
'
../../../modules/platform
'
;
import
{
ExternalHostError
}
from
'
../../../types/errors/external-host-error
'
;
import
{
getCache
}
from
'
../../../util/cache/repository
'
;
import
{
readLocalFile
}
from
'
../../../util/fs
'
;
import
{
getFileList
}
from
'
../../../util/git
'
;
...
...
@@ -51,7 +52,16 @@ export async function detectRepoFileConfig(): Promise<RepoFileConfig> {
const
cache
=
getCache
();
let
{
configFileName
}
=
cache
;
if
(
configFileName
)
{
const
configFileRaw
=
await
platform
.
getRawFile
(
configFileName
);
let
configFileRaw
:
string
|
null
;
try
{
configFileRaw
=
await
platform
.
getRawFile
(
configFileName
);
}
catch
(
err
)
{
// istanbul ignore if
if
(
err
instanceof
ExternalHostError
)
{
throw
err
;
}
configFileRaw
=
null
;
}
if
(
configFileRaw
)
{
let
configFileParsed
=
JSON5
.
parse
(
configFileRaw
);
if
(
configFileName
!==
'
package.json
'
)
{
...
...
@@ -61,6 +71,7 @@ export async function detectRepoFileConfig(): Promise<RepoFileConfig> {
return
{
configFileName
,
configFileParsed
};
// don't return raw 'package.json'
}
else
{
logger
.
debug
(
'
Existing config file no longer exists
'
);
delete
cache
.
configFileName
;
}
}
configFileName
=
(
await
detectConfigFile
())
??
undefined
;
...
...
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