diff --git a/src/Git/Repository.php b/src/Git/Repository.php index 1fe31ce..5f152ea 100644 --- a/src/Git/Repository.php +++ b/src/Git/Repository.php @@ -48,22 +48,19 @@ public static function getFirstCommit(): string } /** - * Get last tag. + * Get last commit hash. */ - public static function getLastTag(): string + public static function getLastCommit(): string { - return self::run("git for-each-ref refs/tags --sort=-creatordate --format='%(refname:strip=2)' --count=1"); + return self::run('git log -1 --pretty=format:%H'); } /** - * Get commit date. + * Get last tag. */ - public static function getCommitDate($hash): string + public static function getLastTag(): string { - $date = self::run("git log -1 --format=%aI {$hash}"); - $today = new DateTime($date); - - return $today->format('Y-m-d'); + return self::run("git for-each-ref refs/tags --sort=-creatordate --format='%(refname:strip=2)' --count=1"); } /** @@ -76,6 +73,17 @@ public static function getLastTagCommit(): string return self::run("git rev-parse --verify {$lastTag}"); } + /** + * Get commit date. + */ + public static function getCommitDate($hash): string + { + $date = self::run("git log -1 --format=%aI {$hash}"); + $today = new DateTime($date); + + return $today->format('Y-m-d'); + } + /** * Get remote url. */