mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 23:30:35 -04:00
Rename GitCommit::FromLogLine and have it accept the full line
This commit is contained in:
parent
e9cf55b53f
commit
df8eac6f82
2 changed files with 6 additions and 4 deletions
|
@ -690,9 +690,8 @@ class Ebook{
|
||||||
$historyEntries = explode("\n", shell_exec('cd ' . escapeshellarg($ebookFromFilesystem->RepoFilesystemPath) . ' && git log -n5 --pretty=format:"%ct %H %s"'));
|
$historyEntries = explode("\n", shell_exec('cd ' . escapeshellarg($ebookFromFilesystem->RepoFilesystemPath) . ' && git log -n5 --pretty=format:"%ct %H %s"'));
|
||||||
|
|
||||||
$gitCommits = [];
|
$gitCommits = [];
|
||||||
foreach($historyEntries as $entry){
|
foreach($historyEntries as $logLine){
|
||||||
$array = explode(' ', $entry, 3);
|
$gitCommits[] = GitCommit::FromLogLine($logLine);
|
||||||
$gitCommits[] = GitCommit::FromLog($array[0], $array[1], $array[2]);
|
|
||||||
}
|
}
|
||||||
$ebookFromFilesystem->GitCommits = $gitCommits;
|
$ebookFromFilesystem->GitCommits = $gitCommits;
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,17 @@ class GitCommit{
|
||||||
/**
|
/**
|
||||||
* @throws Exceptions\InvalidGitCommitException
|
* @throws Exceptions\InvalidGitCommitException
|
||||||
*/
|
*/
|
||||||
public static function FromLog(string $unixTimestamp, string $hash, string $message): GitCommit{
|
public static function FromLogLine(string $logLine): GitCommit{
|
||||||
$instance = new GitCommit();
|
$instance = new GitCommit();
|
||||||
|
list($unixTimestamp, $hash, $message) = explode(' ', $logLine, 3);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$instance->Created = new DateTimeImmutable('@' . $unixTimestamp);
|
$instance->Created = new DateTimeImmutable('@' . $unixTimestamp);
|
||||||
}
|
}
|
||||||
catch(\Exception){
|
catch(\Exception){
|
||||||
throw new Exceptions\InvalidGitCommitException('Invalid timestamp for Git commit.');
|
throw new Exceptions\InvalidGitCommitException('Invalid timestamp for Git commit.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$instance->Message = $message;
|
$instance->Message = $message;
|
||||||
$instance->Hash = $hash;
|
$instance->Hash = $hash;
|
||||||
return $instance;
|
return $instance;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue