-
-
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.
fix: git.log.Change(s) ( Fixes #306 )
- Loading branch information
James Brundage
committed
Sep 28, 2024
1 parent
968f037
commit 71b4e50
Showing
1 changed file
with
29 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<# | ||
.SYNOPSIS | ||
Gets the changes in a git commit | ||
.DESCRIPTION | ||
Gets the changes in a git commit. This function is used to get the changes in a git commit. | ||
The changes are returned as a PSCustomObject with the following properties: | ||
- FilePath: The path of the file that was changed | ||
- LinesChanged: The number of lines changed in the file | ||
- LinesInserted: The number of lines inserted in the file | ||
- LinesDeleted: The number of lines deleted in the file | ||
#> | ||
return @(foreach ($outLine in $this.GitOutputLines) { | ||
if ($outLine -notlike ' *|*') { continue } | ||
$nameOfFile, $fileChanges = $outLine -split '\|' | ||
$nameOfFile = $nameOfFile -replace '^\s+' -replace '\s+$' | ||
$match = [Regex]::Match($fileChanges, "(?<c>\d+)\s(?<i>\+{0,})(?<d>\-{0,})") | ||
$linesChanged = $match.Groups["c"].Value -as [int] | ||
$linesInserted = $match.Groups["i"].Length | ||
$linesDeleted = $match.Groups["d"].Length | ||
[PSCustomObject][Ordered]@{ | ||
PSTypeName = 'git.log.change' | ||
FilePath = $nameOfFile | ||
LinesChanged = $linesChanged | ||
LinesInserted = $linesInserted | ||
LinesDeleted = $linesDeleted | ||
} | ||
}) |