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
5cc37ec7
Unverified
Commit
5cc37ec7
authored
1 year ago
by
Norbert Szulc
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor(manager/pip-compile): Extract getExecOptions method to common (#27149)
parent
7e3c8ca4
No related branches found
Branches containing commit
Tags
38.39.6
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/modules/manager/pip-compile/artifacts.ts
+2
-23
2 additions, 23 deletions
lib/modules/manager/pip-compile/artifacts.ts
lib/modules/manager/pip-compile/common.ts
+28
-0
28 additions, 0 deletions
lib/modules/manager/pip-compile/common.ts
with
30 additions
and
23 deletions
lib/modules/manager/pip-compile/artifacts.ts
+
2
−
23
View file @
5cc37ec7
...
...
@@ -3,10 +3,8 @@ import upath from 'upath';
import
{
TEMPORARY_ERROR
}
from
'
../../../constants/error-messages
'
;
import
{
logger
}
from
'
../../../logger
'
;
import
{
exec
}
from
'
../../../util/exec
'
;
import
type
{
ExecOptions
}
from
'
../../../util/exec/types
'
;
import
{
deleteLocalFile
,
ensureCacheDir
,
readLocalFile
,
writeLocalFile
,
}
from
'
../../../util/fs
'
;
...
...
@@ -16,8 +14,7 @@ import type { UpdateArtifact, UpdateArtifactsResult } from '../types';
import
{
allowedPipArguments
,
constraintLineRegex
,
getPipToolsConstraint
,
getPythonConstraint
,
getExecOptions
,
}
from
'
./common
'
;
export
function
constructPipCompileCmd
(
...
...
@@ -86,25 +83,7 @@ export async function updateArtifacts({
inputFileName
,
outputFileName
,
);
const
constraint
=
getPythonConstraint
(
config
);
const
pipToolsConstraint
=
getPipToolsConstraint
(
config
);
const
execOptions
:
ExecOptions
=
{
cwdFile
:
inputFileName
,
docker
:
{},
toolConstraints
:
[
{
toolName
:
'
python
'
,
constraint
,
},
{
toolName
:
'
pip-tools
'
,
constraint
:
pipToolsConstraint
,
},
],
extraEnv
:
{
PIP_CACHE_DIR
:
await
ensureCacheDir
(
'
pip
'
),
},
};
const
execOptions
=
await
getExecOptions
(
config
,
inputFileName
);
logger
.
trace
({
cmd
},
'
pip-compile command
'
);
await
exec
(
cmd
,
execOptions
);
const
status
=
await
getRepoStatus
();
...
...
This diff is collapsed.
Click to expand it.
lib/modules/manager/pip-compile/common.ts
+
28
−
0
View file @
5cc37ec7
import
is
from
'
@sindresorhus/is
'
;
import
{
logger
}
from
'
../../../logger
'
;
import
type
{
ExecOptions
}
from
'
../../../util/exec/types
'
;
import
{
ensureCacheDir
}
from
'
../../../util/fs
'
;
import
{
regEx
}
from
'
../../../util/regex
'
;
import
type
{
UpdateArtifactsConfig
}
from
'
../types
'
;
...
...
@@ -27,6 +29,32 @@ export function getPipToolsConstraint(config: UpdateArtifactsConfig): string {
return
''
;
}
export
async
function
getExecOptions
(
config
:
UpdateArtifactsConfig
,
inputFileName
:
string
,
):
Promise
<
ExecOptions
>
{
const
constraint
=
getPythonConstraint
(
config
);
const
pipToolsConstraint
=
getPipToolsConstraint
(
config
);
const
execOptions
:
ExecOptions
=
{
cwdFile
:
inputFileName
,
docker
:
{},
toolConstraints
:
[
{
toolName
:
'
python
'
,
constraint
,
},
{
toolName
:
'
pip-tools
'
,
constraint
:
pipToolsConstraint
,
},
],
extraEnv
:
{
PIP_CACHE_DIR
:
await
ensureCacheDir
(
'
pip
'
),
},
};
return
execOptions
;
}
export
const
constraintLineRegex
=
regEx
(
/^
(
#.*
?\r?\n)
+#
{4}
pip-compile
(?<
arguments>.*
?)\r?\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