-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: git.log.Trailer ( Fixes #305 )
- Loading branch information
James Brundage
committed
Sep 28, 2024
1 parent
a1fdc55
commit 1e1ff7f
Showing
3 changed files
with
25 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
@{ | ||
Notes = 'Note' | ||
Trailers = 'Trailer' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<# | ||
.SYNOPSIS | ||
Gets the trailer of a commit | ||
.DESCRIPTION | ||
Gets the trailers of a commit. Git trailers are key-value pairs that are appended to the end of a commit message. | ||
.LINK | ||
https://git-scm.com/docs/git-interpret-trailers | ||
#> | ||
|
||
$lineNumber = 0 | ||
$gitTrailers = [Ordered]@{} | ||
foreach ($commitMessageLine in $this.CommitMessage -split '(?>\r\n|\n)') { | ||
$lineNumber++ | ||
if ($commitMessageLine -notmatch '\s{0,}(?<k>\S+):\s(?<v>[\s\S]+$)' -or $lineNumber -eq 1) { | ||
continue | ||
} | ||
if (-not $gitTrailers[$matches.k]) { | ||
$gitTrailers[$matches.k] = $matches.v | ||
} else { | ||
$gitTrailers[$matches.k] = @($gitTrailers[$matches.k]) + $v | ||
} | ||
} | ||
return $gitTrailers |