Skip to content

Commit 392db51

Browse files
committed
Add formatting of a single hash
1 parent 5f6473d commit 392db51

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/GitChangeLog.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ class GitChangeLog
9292
* @var string Path to a base (changelog) file. The generated changelog can be prepend this file.
9393
*/
9494
public $baseFile;
95+
/**
96+
* @var string Format of a single commit hash. {hash} is replaced by the commit hash.
97+
*/
98+
public $formatHash = '{hash}';
9599
/**
96100
* @var string Value of the oldest tag to include into the generated changelog.
97101
* @see GitChangeLog::setFromTag()
@@ -270,6 +274,10 @@ public function build(): void
270274
// Add commit subjects.
271275
foreach ($data['subjects'] as $subjectKey => &$subject) {
272276
if ($this->options['addHashes']) {
277+
foreach ($data['hashes'][$subjectKey] as &$hash) {
278+
$hash = str_replace('{hash}', $hash, $this->formatHash);
279+
}
280+
unset($hash);
273281
$hashesString = implode(', ', $data['hashes'][$subjectKey]);
274282
$hashesString = str_replace('{hashes}', $hashesString, $this->formatHashes);
275283
}

0 commit comments

Comments
 (0)