Skip to content
Snippets Groups Projects
Commit 6857146a authored by jurgenhaas's avatar jurgenhaas
Browse files

composer/plugin/docker4drupal#33 Better handling of git lfs as well

parent 7f9a8386
No related branches found
No related tags found
No related merge requests found
......@@ -136,4 +136,11 @@ abstract class BaseHandler implements BaseHandlerInterface {
Utils::gitIgnore($pattern);
}
/**
* {@inheritdoc}
*/
public function gitLFS($pattern) {
Utils::gitLFS($pattern);
}
}
......@@ -74,4 +74,12 @@ interface BaseHandlerInterface {
*/
public function gitIgnore($pattern);
/**
* Add the given pattern to git lfs if necessary.
*
* @param string $pattern
* The pattern which should be added.
*/
public function gitLFS($pattern);
}
......@@ -43,6 +43,11 @@ final class Utils {
*/
private static $ignoredGitPatterns;
/**
* @var string
*/
private static $lfsGitPatterns;
/**
* Utils constructor.
*
......@@ -202,4 +207,22 @@ final class Utils {
self::git('ignore ' . $pattern);
}
/**
* @param string $pattern
*/
public static function gitLFS($pattern) {
if (self::$lfsGitPatterns === NULL) {
$output = [];
exec('git lfs track', $output);
self::$lfsGitPatterns = implode(PHP_EOL, $output);
}
if (strpos(self::$lfsGitPatterns, $pattern)) {
return;
}
self::$lfsGitPatterns = $pattern . PHP_EOL;
self::git('lfs track ' . $pattern);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment