Gitonomy\Git\Repository::getHeadCommit PHP Method

getHeadCommit() public method

Returns the HEAD resolved as a commit.
public getHeadCommit ( ) : Gitonomy\Git\Commit | null
return Gitonomy\Git\Commit | null returns a Commit or ``null`` if repository is empty
    public function getHeadCommit()
    {
        $head = $this->getHead();
        if ($head instanceof Reference) {
            return $head->getCommit();
        }
        return $head;
    }

Usage Example

Beispiel #1
0
 /**
  * Create a new GitDown parser instance.
  *
  * @param $directory string
  * @throws RuntimeException if GitRuntimeException caught
  * @throws InvalidArgumentException if GitInvalidArgumentException caught
  */
 public function __construct($directory)
 {
     try {
         $this->repository = new Repository($directory);
         $this->commit = $this->repository->getHeadCommit();
     } catch (GitInvalidArgumentException $e) {
         throw new InvalidArgumentException($e->getMessage());
     } catch (GitRuntimeException $e) {
         throw new RuntimeException($e->getMessage());
     }
 }
All Usage Examples Of Gitonomy\Git\Repository::getHeadCommit