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
ea7419c6
Commit
ea7419c6
authored
2 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
#6
Add support to keep files and directories that are...
#6
Add support to keep files and directories that are not contained in the repository
parent
647caec3
No related branches found
No related tags found
1 merge request
!3
Merging develop into main
Pipeline
#548933
passed
2 years ago
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Handler.php
+49
-11
49 additions, 11 deletions
src/Handler.php
with
49 additions
and
11 deletions
src/Handler.php
+
49
−
11
View file @
ea7419c6
...
@@ -2,14 +2,12 @@
...
@@ -2,14 +2,12 @@
namespace
LakeDrops\DorgFlow
;
namespace
LakeDrops\DorgFlow
;
use
Exception
;
use
GitElephant\Command\ResetCommand
;
use
GitElephant\Repository
;
use
GitElephant\Repository
;
use
LakeDrops\Component\Composer\BaseHandler
;
use
LakeDrops\Component\Composer\BaseHandler
;
use
Symfony\Component\Filesystem\Filesystem
;
use
Symfony\Component\Filesystem\Filesystem
;
/**
/**
*
Class
Handler.
* Handler
class for the Dorgflow plugin
.
*
*
* @package LakeDrops\DorgFlow
* @package LakeDrops\DorgFlow
*/
*/
...
@@ -50,10 +48,10 @@ class Handler extends BaseHandler {
...
@@ -50,10 +48,10 @@ class Handler extends BaseHandler {
$installationManager
=
$this
->
composer
->
getInstallationManager
();
$installationManager
=
$this
->
composer
->
getInstallationManager
();
foreach
([
foreach
([
'projects'
=>
'git.drupal.org:project'
,
'projects'
=>
'git.drupal.org:project'
,
'drupalspoons'
=>
'gitlab.com:drupalspoons'
,
'drupalspoons'
=>
'gitlab.com:drupalspoons'
,
'selfhosted'
=>
FALSE
,
'selfhosted'
=>
FALSE
,
]
as
$type
=>
$url
)
{
]
as
$type
=>
$url
)
{
if
(
$this
->
config
->
readValue
(
$type
)
===
NULL
)
{
if
(
$this
->
config
->
readValue
(
$type
)
===
NULL
)
{
continue
;
continue
;
}
}
...
@@ -86,7 +84,9 @@ class Handler extends BaseHandler {
...
@@ -86,7 +84,9 @@ class Handler extends BaseHandler {
}
}
$path
=
$installationManager
->
getInstallPath
(
$package
);
$path
=
$installationManager
->
getInstallPath
(
$package
);
$this
->
io
->
write
(
"-
$project
=>
$path
"
,
TRUE
);
$this
->
io
->
write
(
"-
$project
=>
$path
"
,
TRUE
);
$this
->
keepObjects
(
$project
);
$this
->
prepareWorkingDirectory
(
$path
,
$projectname
,
$version
,
$fullUrl
);
$this
->
prepareWorkingDirectory
(
$path
,
$projectname
,
$version
,
$fullUrl
);
$this
->
restoreObjects
(
$project
);
}
}
}
}
}
}
...
@@ -112,11 +112,12 @@ class Handler extends BaseHandler {
...
@@ -112,11 +112,12 @@ class Handler extends BaseHandler {
try
{
try
{
$origin
=
$repository
->
getRemote
(
'origin'
,
FALSE
);
$origin
=
$repository
->
getRemote
(
'origin'
,
FALSE
);
if
(
$origin
&&
$origin
->
getFetchURL
()
===
$uri
)
{
if
(
$origin
->
getFetchURL
()
===
$uri
)
{
// 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.
}
}
...
@@ -177,12 +178,13 @@ class Handler extends BaseHandler {
...
@@ -177,12 +178,13 @@ class Handler extends BaseHandler {
$repository
=
Repository
::
open
(
$path
);
$repository
=
Repository
::
open
(
$path
);
try
{
try
{
$origin
=
$repository
->
getRemote
(
$remote
,
FALSE
);
$origin
=
$repository
->
getRemote
(
$remote
,
FALSE
);
if
(
$origin
&&
$origin
->
getFetchURL
()
===
$uri
)
{
if
(
$origin
->
getFetchURL
()
===
$uri
)
{
// Already setup correctly.
// Already setup correctly.
$this
->
io
->
write
(
'Already available.'
);
$this
->
io
->
write
(
'Already available.'
);
return
;
return
;
}
}
}
catch
(
Exception
$ex
)
{
}
catch
(
\Exception
$ex
)
{
// Ignore the exception and conitue setup.
// Ignore the exception and conitue setup.
}
}
$repository
->
addRemote
(
$remote
,
$uri
);
$repository
->
addRemote
(
$remote
,
$uri
);
...
@@ -190,4 +192,40 @@ class Handler extends BaseHandler {
...
@@ -190,4 +192,40 @@ class Handler extends BaseHandler {
$this
->
io
->
write
(
'Successfully added issue fork.'
);
$this
->
io
->
write
(
'Successfully added issue fork.'
);
}
}
/**
* Move files and directories to keep to the /tmp directory.
*
* @param string $project
* The project name.
*/
private
function
keepObjects
(
string
$project
):
void
{
if
(
$objects
=
$this
->
config
->
readValue
([
'keep'
,
$project
]))
{
$fs
=
new
Filesystem
();
foreach
(
$objects
as
$id
=>
$object
)
{
if
(
file_exists
(
$object
))
{
$this
->
io
->
write
(
' - keeping '
.
$object
);
$fs
->
rename
(
$object
,
'/tmp/dorgflow-keep-'
.
$id
,
TRUE
);
}
}
}
}
/**
* Move files and directories to keep from the /tmp directory.
*
* @param string $project
* The project name.
*/
private
function
restoreObjects
(
string
$project
):
void
{
if
(
$objects
=
$this
->
config
->
readValue
([
'keep'
,
$project
]))
{
$fs
=
new
Filesystem
();
foreach
(
$objects
as
$id
=>
$object
)
{
if
(
file_exists
(
'/tmp/dorgflow-keep-'
.
$id
))
{
$this
->
io
->
write
(
' - restoring '
.
$object
);
$fs
->
rename
(
'/tmp/dorgflow-keep-'
.
$id
,
$object
,
TRUE
);
}
}
}
}
}
}
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