Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
composer.json Utils
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
library
composer.json Utils
Commits
e805a3e4
Commit
e805a3e4
authored
6 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
composer/plugin/docker4drupal#33
Better handling of git ignore
parent
a7e8ba09
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
BaseHandler.php
+26
-0
26 additions, 0 deletions
BaseHandler.php
BaseHandlerInterface.php
+8
-0
8 additions, 0 deletions
BaseHandlerInterface.php
with
34 additions
and
0 deletions
BaseHandler.php
+
26
−
0
View file @
e805a3e4
...
...
@@ -47,6 +47,11 @@ abstract class BaseHandler implements BaseHandlerInterface {
*/
protected
$drupalCorePackage
;
/**
* @var string[]
*/
protected
$ignoredGitPatterns
;
/**
* Handler constructor.
*
...
...
@@ -129,4 +134,25 @@ abstract class BaseHandler implements BaseHandlerInterface {
passthru
(
escapeshellcmd
(
'git -c "user.email=composer@lakedrops.com" '
.
$command
));
}
/**
* {@inheritdoc}
*/
public
function
gitIgnore
(
$pattern
)
{
if
(
$this
->
ignoredGitPatterns
===
NULL
)
{
if
(
file_exists
(
'.gitignore'
))
{
$this
->
ignoredGitPatterns
=
explode
(
PHP_EOL
,
file_get_contents
(
'.gitignore'
));
}
else
{
$this
->
ignoredGitPatterns
=
[];
}
}
if
(
\in_array
(
$pattern
,
$this
->
ignoredGitPatterns
,
TRUE
))
{
return
;
}
$this
->
ignoredGitPatterns
[]
=
$pattern
;
$this
->
git
(
'ignore '
.
$pattern
);
}
}
This diff is collapsed.
Click to expand it.
BaseHandlerInterface.php
+
8
−
0
View file @
e805a3e4
...
...
@@ -66,4 +66,12 @@ interface BaseHandlerInterface {
*/
public
function
git
(
$command
);
/**
* Add the given pattern to gitignore if necessary.
*
* @param string $pattern
* The pattern which should be ignored.
*/
public
function
gitIgnore
(
$pattern
);
}
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