From a97b72f579a9692b0f6a0a34d8fcfd329b9b338e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Perr=C3=A9al?= <guillaume.perreal@irstea.fr> Date: Thu, 3 Sep 2020 10:55:33 +0200 Subject: [PATCH] =?UTF-8?q?Recherche=20le=20d=C3=A9p=C3=B4t=20.git=20dans?= =?UTF-8?q?=20les=20parents=20s'il=20n'est=20pas=20trouv=C3=A9=20en=20loca?= =?UTF-8?q?l.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Config.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Config.php b/src/Config.php index cf9b204..e153c0d 100644 --- a/src/Config.php +++ b/src/Config.php @@ -167,7 +167,8 @@ final class Config extends PhpCsFixerConfig $fileLocator = new FileLocator($callerPath); $composerPackage = new ComposerPackage($fileLocator); - $gitRepository = new GitRepository($callerPath); + $repoPath = self::findGitRepository($callerPath); + $gitRepository = new GitRepository($repoPath); $headerProvider = new FormattedHeaderProvider( new ChainTemplateProvider( @@ -182,4 +183,13 @@ final class Config extends PhpCsFixerConfig return new self($composerPackage, $headerProvider); } + + private static function findGitRepository(string $path): string + { + while (!is_dir($path . '/.git') && $path !== '/') { + $path = basename($path); + } + + return $path; + } } -- GitLab