Skip to content

Commit

Permalink
fix: git.log.Change(s) ( Fixes #306 )
Browse files Browse the repository at this point in the history
  • Loading branch information
James Brundage committed Sep 28, 2024
1 parent 968f037 commit 71b4e50
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Types/git.log/get_Change.ps1
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
}
})

0 comments on commit 71b4e50

Please sign in to comment.