Skip to content

Commit

Permalink
Fixed method GitDirectory::__toString()
Browse files Browse the repository at this point in the history
  • Loading branch information
tg666 committed Apr 30, 2022
1 parent 86e9b5f commit aece636
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/Repository/LocalDirectory/GitDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class GitDirectory

private ?string $workingDirectoryPath = NULL;

private ?string $gitDirectory = NULL;
private ?string $gitDirectory;

private string $directoryName;

Expand Down Expand Up @@ -68,22 +68,18 @@ public function __toString(): string

$workingDirectory = $this->getWorkingDirectoryPath();

while (FALSE !== $workingDirectory) {
do {
$currentDirectory = $workingDirectory;
$gitDirectory = $workingDirectory . DIRECTORY_SEPARATOR . $this->directoryName;

if (is_dir($gitDirectory)) {
return $this->gitDirectory = $gitDirectory;
}

$workingDirectory = dirname($workingDirectory) . '';
$workingDirectory = dirname($workingDirectory);
} while ($workingDirectory !== $currentDirectory);

if ($workingDirectory === $currentDirectory) {
break;
}
}

throw GitDirectoryException::gitDirectoryNotFound($this->workingDirectory);
throw GitDirectoryException::gitDirectoryNotFound($workingDirectory);
}

/**
Expand Down

0 comments on commit aece636

Please sign in to comment.