Public/Update-GitRepository.ps1
using module "..\Private\RepositoryInfo.psm1" function Update-GitRepository { [CmdletBinding()] [OutputType([Boolean])] Param( [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [RepositoryInfo[]]$RepositoryInfo, [Parameter(Position = 1, ValueFromPipeline = $false)] [string]$Message = "Backup $env:computername - DotupPsGitKit", [Parameter(Position = 2, ValueFromPipeline = $false)] [bool]$Stage = $true, [bool]$Add = $true ) begin { Write-Debug "Begin Update-GitRepository" } process { foreach ($item in $RepositoryInfo) { if ($Add -and $item.State -eq "untracked_files" ) { $gitcommit = git -C $item.DirectoryInfo.FullName add -A } if ($Stage) { $gitcommit = git -C $item.DirectoryInfo.FullName commit -m $Message -a } else { $gitcommit = git -C $item.DirectoryInfo.FullName commit -m $Message } if (-not [string]::IsNullOrEmpty($gitcommit)) { write-host "gitlog: $gitcommit" } return $true } } end { Write-Debug "End Update-GitRepository" } } |