Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automatic_updates
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
automatic_updates
Commits
80514f0d
Commit
80514f0d
authored
1 year ago
by
Ted Bowman
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3409491
by tedbow: Add handling of the Composer dependencies to the conversion script
parent
9405be2e
No related branches found
No related tags found
1 merge request
!1001
Resolve #3409491 "Gitlab"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/src/ConverterCommand.php
+52
-33
52 additions, 33 deletions
scripts/src/ConverterCommand.php
with
52 additions
and
33 deletions
scripts/src/ConverterCommand.php
+
52
−
33
View file @
80514f0d
...
...
@@ -29,9 +29,9 @@ class ConverterCommand extends Command {
private
string
$core_dir
;
private
string
$core_branch
;
private
string
|
null
$core_branch
;
private
string
$contrib_branch
;
private
string
|
null
$contrib_branch
;
private
bool
$package_manager_only
;
...
...
@@ -43,6 +43,20 @@ class ConverterCommand extends Command {
private
bool
$skipCoreChecks
;
/**
* {@inheritdoc}
*/
protected
function
configure
()
{
$this
->
addArgument
(
'core_dir'
,
InputArgument
::
REQUIRED
,
'The path to the root of Drupal Core'
);
$this
->
addArgument
(
'core_branch'
,
InputArgument
::
OPTIONAL
,
'The core merge request branch'
);
$this
->
addArgument
(
'contrib_branch'
,
InputArgument
::
OPTIONAL
,
'The contrib branch to switch to'
,
'3.0.x'
);
$this
->
addOption
(
'package_manager_only'
,
NULL
,
InputOption
::
VALUE_NONE
,
'Only convert package manager'
);
$this
->
addOption
(
'core_target_branch'
,
NULL
,
InputOption
::
VALUE_REQUIRED
,
'The core target branch'
,
'11.x'
);
$this
->
addOption
(
'skip_core_checks'
,
NULL
,
InputOption
::
VALUE_NONE
,
'Skip core checks'
);
$this
->
addOption
(
'no_commit'
,
NULL
,
InputOption
::
VALUE_NONE
,
'Do not make commit'
);
$this
->
addOption
(
'gitlabci'
,
NULL
,
InputOption
::
VALUE_NONE
,
'Run in Gitlab CI'
);
}
/**
* {@inheritdoc}
*/
...
...
@@ -55,28 +69,46 @@ class ConverterCommand extends Command {
$this
->
contrib_dir
=
realpath
(
__DIR__
.
'/../..'
);
$this
->
skipCoreChecks
=
$input
->
getOption
(
'skip_core_checks'
);
$this
->
no_commit
=
$input
->
getOption
(
'no_commit'
);
$this
->
gitlabci
=
$input
->
getOption
(
'gitlabci'
);
if
(
!
$this
->
gitlabci
)
{
if
(
empty
(
$this
->
core_branch
))
{
throw
new
\Exception
(
"core_branch is required if not on gitlabci"
);
}
}
else
{
if
(
!
empty
(
$this
->
core_branch
))
{
throw
new
\Exception
(
"branches are not allowed on gitlabci"
);
}
}
// Esnure core_dir is a directory.
if
(
!
is_dir
(
$this
->
core_dir
))
{
throw
new
\Exception
(
"
$this->core_dir
is not a directory."
);
}
// Switch to core_target_branch to ensure it is clean.
chdir
(
$this
->
core_dir
);
static
::
switchToBranch
(
$this
->
core_target_branch
);
// Git pull to ensure we are up to date.
static
::
executeCommand
(
'git pull'
);
// change back the previous directory.
chdir
(
$this
->
contrib_dir
);
// Ensure we are on the correct branches.
static
::
switchToBranches
(
$this
->
core_dir
,
$this
->
core_branch
,
$this
->
contrib_branch
);
// Switch to the core directory and checkout the files and folders that this
// conversion script will automatically update based on our composer.json
// file and our dictionary.txt file.
chdir
(
$this
->
core_dir
);
static
::
executeCommand
(
"git checkout
{
$this
->
core_target_branch
}
-- composer.json"
);
static
::
executeCommand
(
"git checkout
{
$this
->
core_target_branch
}
-- composer.lock"
);
static
::
executeCommand
(
"git checkout
{
$this
->
core_target_branch
}
-- composer"
);
static
::
executeCommand
(
"git checkout
{
$this
->
core_target_branch
}
-- core/composer.json"
);
static
::
executeCommand
(
"git checkout
{
$this
->
core_target_branch
}
-- core/misc/cspell/dictionary.txt"
);
if
(
$this
->
gitlabci
)
{
$this
->
no_commit
=
TRUE
;
$this
->
skipCoreChecks
=
TRUE
;
}
else
{
// Ensure the core directory is clean.
static
::
switchToBranch
(
$this
->
core_target_branch
);
// Git pull to ensure we are up to date.
static
::
executeCommand
(
'git pull'
);
// change back the previous directory.
chdir
(
$this
->
contrib_dir
);
// Ensure we are on the correct branches.
static
::
switchToBranches
(
$this
->
core_dir
,
$this
->
core_branch
,
$this
->
contrib_branch
);
// Switch to the core directory and checkout the files and folders that this
// conversion script will automatically update based on our composer.json
// file and our dictionary.txt file.
chdir
(
$this
->
core_dir
);
static
::
executeCommand
(
"git checkout
{
$this
->
core_target_branch
}
-- composer.json"
);
static
::
executeCommand
(
"git checkout
{
$this
->
core_target_branch
}
-- composer.lock"
);
static
::
executeCommand
(
"git checkout
{
$this
->
core_target_branch
}
-- composer"
);
static
::
executeCommand
(
"git checkout
{
$this
->
core_target_branch
}
-- core/composer.json"
);
static
::
executeCommand
(
"git checkout
{
$this
->
core_target_branch
}
-- core/misc/cspell/dictionary.txt"
);
}
// Switch to the core directory and require all of the packages there are in
// this module's composer.json require section.
...
...
@@ -121,19 +153,6 @@ class ConverterCommand extends Command {
}
}
/**
* {@inheritdoc}
*/
protected
function
configure
()
{
$this
->
addArgument
(
'core_dir'
,
InputArgument
::
REQUIRED
,
'The path to the root of Drupal Core'
);
$this
->
addArgument
(
'core_branch'
,
InputArgument
::
REQUIRED
,
'The core merge request branch'
);
$this
->
addArgument
(
'contrib_branch'
,
InputArgument
::
OPTIONAL
,
'The contrib branch to switch to'
,
'3.0.x'
);
$this
->
addOption
(
'package_manager_only'
,
NULL
,
InputOption
::
VALUE_NONE
,
'Only convert package manager'
);
$this
->
addOption
(
'core_target_branch'
,
NULL
,
InputOption
::
VALUE_REQUIRED
,
'The core target branch'
,
'11.x'
);
$this
->
addOption
(
'skip_core_checks'
,
NULL
,
InputOption
::
VALUE_NONE
,
'Skip core checks'
);
$this
->
addOption
(
'no_commit'
,
NULL
,
InputOption
::
VALUE_NONE
,
'Do not make commit'
);
}
/**
* Prints message.
*
...
...
@@ -472,7 +491,7 @@ class ConverterCommand extends Command {
chdir
(
$core_dir
);
// Make sure ALL files are committed, including the core/modules/package_manager/tests/fixtures/fake_site/core directory!
shell_exec
(
'git add -f core/modules/package_manager'
);
shell_exec
(
'git add
core
'
);
shell_exec
(
'git add
.
'
);
shell_exec
(
"git commit -m 'Contrib:
$message
- https://git.drupalcode.org/project/automatic_updates/-/commit/
$hash
'"
);
}
...
...
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