Skip to content

Commit

Permalink
Add formatting of a single hash
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiLive committed Oct 22, 2020
1 parent 5f6473d commit 392db51
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/GitChangeLog.php
Expand Up @@ -92,6 +92,10 @@ class GitChangeLog
* @var string Path to a base (changelog) file. The generated changelog can be prepend this file.
*/
public $baseFile;
/**
* @var string Format of a single commit hash. {hash} is replaced by the commit hash.
*/
public $formatHash = '{hash}';
/**
* @var string Value of the oldest tag to include into the generated changelog.
* @see GitChangeLog::setFromTag()
Expand Down Expand Up @@ -270,6 +274,10 @@ public function build(): void
// Add commit subjects.
foreach ($data['subjects'] as $subjectKey => &$subject) {
if ($this->options['addHashes']) {
foreach ($data['hashes'][$subjectKey] as &$hash) {
$hash = str_replace('{hash}', $hash, $this->formatHash);
}
unset($hash);
$hashesString = implode(', ', $data['hashes'][$subjectKey]);
$hashesString = str_replace('{hashes}', $hashesString, $this->formatHashes);
}
Expand Down

0 comments on commit 392db51

Please sign in to comment.