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
StartAutomating authored and StartAutomating committed Sep 28, 2024
1 parent 71b4e50 commit ee87242
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions ugit.types.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,41 @@ git revert $this.CommitHash @args
Pop-Location
</Script>
</ScriptMethod>
<ScriptProperty>
<Name>Change</Name>
<GetScriptBlock>
&lt;#
.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
#&gt;
return @(foreach ($outLine in $this.GitOutputLines) {
if ($outLine -notlike ' *|*') { continue }
$nameOfFile, $fileChanges = $outLine -split '\|'
$nameOfFile = $nameOfFile -replace '^\s+' -replace '\s+$'
$match = [Regex]::Match($fileChanges, "(?&lt;c&gt;\d+)\s(?&lt;i&gt;\+{0,})(?&lt;d&gt;\-{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
}
})

</GetScriptBlock>
</ScriptProperty>
<ScriptProperty>
<Name>CommitType</Name>
<GetScriptBlock>
Expand Down

0 comments on commit ee87242

Please sign in to comment.