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
b06af660
Unverified
Commit
b06af660
authored
1 year ago
by
Sergei Zharinov
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor(regex): Inverse dependency on logger util (#26997)
parent
3ea3fa26
No related branches found
Branches containing commit
Tags
30.0.0
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/util/regex.ts
+18
-9
18 additions, 9 deletions
lib/util/regex.ts
lib/workers/global/index.ts
+13
-0
13 additions, 0 deletions
lib/workers/global/index.ts
with
31 additions
and
9 deletions
lib/util/regex.ts
+
18
−
9
View file @
b06af660
...
...
@@ -2,24 +2,34 @@ import is from '@sindresorhus/is';
import
{
CONFIG_VALIDATION
}
from
'
../constants/error-messages
'
;
import
{
re2
}
from
'
../expose.cjs
'
;
import
{
logger
}
from
'
../logger
'
;
let
RegEx
:
RegExpConstructor
;
const
cache
=
new
Map
<
string
,
RegExp
>
();
if
(
!
process
.
env
.
RENOVATE_X_IGNORE_RE2
)
{
type
RegExpEngineStatus
=
|
{
type
:
'
available
'
}
|
{
type
:
'
unavailable
'
;
err
:
Error
;
}
|
{
type
:
'
ignored
'
};
let
status
:
RegExpEngineStatus
;
let
RegEx
:
RegExpConstructor
=
RegExp
;
// istanbul ignore next
if
(
process
.
env
.
RENOVATE_X_IGNORE_RE2
)
{
status
=
{
type
:
'
ignored
'
};
}
else
{
try
{
const
RE2
=
re2
();
// Test if native is working
new
RE2
(
'
.*
'
).
exec
(
'
test
'
);
logger
.
debug
(
'
Using RE2 as regex engine
'
);
RegEx
=
RE2
;
status
=
{
type
:
'
available
'
};
}
catch
(
err
)
{
logger
.
warn
({
err
},
'
RE2 not us
able,
falling back to RegExp
'
)
;
status
=
{
type
:
'
unavail
able
'
,
err
}
;
}
}
RegEx
??=
RegExp
;
export
const
regexEngineStatus
=
status
;
export
function
regEx
(
pattern
:
string
|
RegExp
,
...
...
@@ -49,7 +59,6 @@ export function regEx(
}
return
instance
;
}
catch
(
err
)
{
logger
.
trace
({
err
},
'
RegEx constructor error
'
);
const
error
=
new
Error
(
CONFIG_VALIDATION
);
error
.
validationMessage
=
err
.
message
;
error
.
validationSource
=
pattern
.
toString
();
...
...
This diff is collapsed.
Click to expand it.
lib/workers/global/index.ts
+
13
−
0
View file @
b06af660
...
...
@@ -20,6 +20,7 @@ import { getProblems, logger, setMeta } from '../../logger';
import
*
as
hostRules
from
'
../../util/host-rules
'
;
import
*
as
queue
from
'
../../util/http/queue
'
;
import
*
as
throttle
from
'
../../util/http/throttle
'
;
import
{
regexEngineStatus
}
from
'
../../util/regex
'
;
import
{
addSecretForSanitizing
}
from
'
../../util/sanitize
'
;
import
*
as
repositoryWorker
from
'
../repository
'
;
import
{
autodiscoverRepositories
}
from
'
./autodiscover
'
;
...
...
@@ -111,6 +112,18 @@ export async function resolveGlobalExtends(
}
export
async
function
start
():
Promise
<
number
>
{
// istanbul ignore next
if
(
regexEngineStatus
.
type
===
'
available
'
)
{
logger
.
debug
(
'
Using RE2 regex engine
'
);
}
else
if
(
regexEngineStatus
.
type
===
'
unavailable
'
)
{
logger
.
warn
(
{
err
:
regexEngineStatus
.
err
},
'
RE2 not usable, falling back to RegExp
'
,
);
}
else
if
(
regexEngineStatus
.
type
===
'
ignored
'
)
{
logger
.
debug
(
'
RE2 regex engine is ignored via RENOVATE_X_IGNORE_RE2
'
);
}
let
config
:
AllConfig
;
try
{
if
(
is
.
nonEmptyStringAndNotWhitespace
(
process
.
env
.
AWS_SECRET_ACCESS_KEY
))
{
...
...
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