<?php
declare(strict_types=1);
namespace GitList\Repository;
use GitList\Repository;
class Commitish
{
protected string $hash;
protected ?string $path = null;
public function __construct(Repository $repository, string $commitish)
{
$this->hash = strtok($commitish, '/');
$revs = [...$repository->getBranches(), ...$repository->getTags()];
foreach ($revs as $rev) {
if (false === ($pos = strpos($commitish, (string) $rev->getName()))) {
continue;
}
$this->hash = $rev->getName();
$revSuffix = substr($commitish, strlen($this->hash));