Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dorgflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
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
Composer
plugin
Dorgflow
Commits
4f488a9c
Commit
4f488a9c
authored
3 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
#7
Add command to download issue fork
parent
ac313867
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
ahoy.yml
+3
-0
3 additions, 0 deletions
ahoy.yml
src/CommandProvider.php
+1
-0
1 addition, 0 deletions
src/CommandProvider.php
src/Handler.php
+47
-3
47 additions, 3 deletions
src/Handler.php
src/IssueForkCommand.php
+42
-0
42 additions, 0 deletions
src/IssueForkCommand.php
with
93 additions
and
3 deletions
ahoy.yml
+
3
−
0
View file @
4f488a9c
...
@@ -17,3 +17,6 @@ commands:
...
@@ -17,3 +17,6 @@ commands:
env -i $(cat .env | xargs) >.env
env -i $(cat .env | xargs) >.env
composer lakedrops:dorgflow --no-interaction
composer lakedrops:dorgflow --no-interaction
usage
:
Turn off dorgflow
usage
:
Turn off dorgflow
issue
:
cmd
:
composer lakedrops:issuefork "$@" --no-interaction
usage
:
Load an issue fork for a specific project from drupal.org
This diff is collapsed.
Click to expand it.
src/CommandProvider.php
+
1
−
0
View file @
4f488a9c
...
@@ -12,6 +12,7 @@ class CommandProvider implements CommandProviderCapability {
...
@@ -12,6 +12,7 @@ class CommandProvider implements CommandProviderCapability {
public
function
getCommands
():
array
{
public
function
getCommands
():
array
{
return
[
return
[
new
PrepareCommand
(),
new
PrepareCommand
(),
new
IssueForkCommand
(),
];
];
}
}
}
}
This diff is collapsed.
Click to expand it.
src/Handler.php
+
47
−
3
View file @
4f488a9c
...
@@ -116,8 +116,7 @@ class Handler extends BaseHandler {
...
@@ -116,8 +116,7 @@ class Handler extends BaseHandler {
// Already setup correctly.
// Already setup correctly.
return
;
return
;
}
}
}
}
catch
(
Exception
$ex
)
{
catch
(
Exception
$ex
)
{
// Ignore the exception and conitue setup.
// Ignore the exception and conitue setup.
}
}
...
@@ -126,7 +125,6 @@ class Handler extends BaseHandler {
...
@@ -126,7 +125,6 @@ class Handler extends BaseHandler {
$fs
->
mkdir
(
$path
);
$fs
->
mkdir
(
$path
);
$repository
->
init
();
$repository
->
init
();
$repository
->
addRemote
(
'origin'
,
$uri
);
$repository
->
addRemote
(
'origin'
,
$uri
);
$repository
->
getCaller
()
->
execute
(
'config --add remote.origin.fetch "+refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*"'
);
$repository
->
fetch
();
$repository
->
fetch
();
$repository
->
checkout
(
$version
);
$repository
->
checkout
(
$version
);
...
@@ -134,4 +132,50 @@ class Handler extends BaseHandler {
...
@@ -134,4 +132,50 @@ class Handler extends BaseHandler {
$this
->
io
->
write
(
' - completed'
,
TRUE
);
$this
->
io
->
write
(
' - completed'
,
TRUE
);
}
}
/**
* Load an issue fork for a specific project from drupal.org.
*/
public
function
loadIssueFork
(
string
$project
,
string
$issue
):
void
{
// We only do the fancy stuff for developers.
if
(
!
$this
->
isDevMode
()
||
$this
->
isCiContext
())
{
return
;
}
$this
->
init
();
$dorgflow
=
$this
->
env
->
receiveGlobal
(
'DORGFLOW'
,
'Dorgflow'
,
'0'
);
if
(
empty
(
$dorgflow
))
{
$this
->
io
->
error
(
'Dorgflow is not enabled.'
);
return
;
}
$installationManager
=
$this
->
composer
->
getInstallationManager
();
$package
=
$this
->
getPackage
(
'drupal/'
.
$project
);
if
(
$package
===
NULL
)
{
$this
->
io
->
error
(
'Project not installed.'
);
return
;
}
$path
=
$installationManager
->
getInstallPath
(
$package
);
if
(
!
file_exists
(
$path
))
{
$this
->
io
->
error
(
'Installation path not found: '
.
$path
);
return
;
}
$uri
=
'git@git.drupal.org:issue/'
.
$project
.
'-'
.
$issue
.
'.git'
;
$remote
=
$project
.
'-issue-'
.
$issue
;
$repository
=
Repository
::
open
(
$path
);
try
{
$origin
=
$repository
->
getRemote
(
$remote
,
FALSE
);
if
(
$origin
&&
$origin
->
getFetchURL
()
===
$uri
)
{
// Already setup correctly.
$this
->
io
->
info
(
'Already available.'
);
return
;
}
}
catch
(
Exception
$ex
)
{
// Ignore the exception and conitue setup.
}
$repository
->
addRemote
(
$remote
,
$uri
);
$repository
->
fetch
(
$remote
);
$this
->
io
->
info
(
'Successfully added issue fork.'
);
}
}
}
This diff is collapsed.
Click to expand it.
src/IssueForkCommand.php
0 → 100644
+
42
−
0
View file @
4f488a9c
<?php
namespace
LakeDrops\DorgFlow
;
use
LakeDrops\Component\Composer\BaseCommand
;
use
Symfony\Component\Console\Input\InputArgument
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Output\OutputInterface
;
class
IssueForkCommand
extends
BaseCommand
{
/**
* {@inheritdoc}
*/
protected
function
configure
():
void
{
parent
::
configure
();
$this
->
setName
(
'lakedrops:issuefork'
)
->
addArgument
(
'Project'
,
InputArgument
::
REQUIRED
,
'Name of the project, e.g. core'
)
->
addArgument
(
'Issue'
,
InputArgument
::
REQUIRED
,
'Number fo the issue'
)
->
setDescription
(
'Load an issue fork for a specific project from drupal.org.'
);
}
/**
* {@inheritdoc}
*/
public
function
getHandlerClass
():
string
{
return
Handler
::
class
;
}
/**
* {@inheritdoc}
*/
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
):
int
{
parent
::
execute
(
$input
,
$output
);
/** @var Handler $handler */
$handler
=
$this
->
handler
;
$handler
->
loadIssueFork
(
$input
->
getArgument
(
'Project'
),
$input
->
getArgument
(
'Issue'
));
return
0
;
}
}
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