diff --git a/Types/git.log/get_Change.ps1 b/Types/git.log/get_Change.ps1 new file mode 100644 index 00000000..e9011874 --- /dev/null +++ b/Types/git.log/get_Change.ps1 @@ -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, "(?\d+)\s(?\+{0,})(?\-{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 + } +})