Public/Update-GitRepository.ps1


function Update-GitRepository {
  [CmdletBinding()]
  [OutputType([Boolean])]
  Param(
    [Parameter()]
    [System.IO.DirectoryInfo]$Item,
    [Parameter()]
    [string]$Message = "DotupPsGitKit",
    [bool]$Stage
  )

  $isGitFolder = Get-IsGitRepository $Item

  if ($isGitFolder) {

    if ($Stage) {      
      $gitcommit = git -C $Item.FullName commit -m $Message -a
    } else{
      $gitcommit = git -C $Item.FullName commit -m $Message
    }

    if (-not [string]::IsNullOrEmpty($gitcommit)) {
      write-host "gitlog: $gitcommit"
    }

  }
  else {
    throw "ArgumentException: Directory is not a git repository"
  }
    
  return $true
}

Update-GitRepository