git related improvements and implementations

+ Get-GitRepo - Clone or update a repo, with tag support
+ Get-GitHubReleaseTag - Grab tag from latest release page
+ Refresh-GitRepo - Stage all possible changes, discarding any
previously stageds changes
= GitHub repo is now git repo - as some code isn't GitHub specific
+ cat Alias for Get-Content
= Get-PossiblArguments improvement
= Invoke-WebDownload fix
= dcedit fixing bad argument processing
This commit is contained in:
lksz 2021-04-04 14:42:29 -04:00
parent aa44d120e4
commit 8a93a0f123
11 changed files with 85 additions and 11 deletions

29
git/Get-GitRepo.ps1 Normal file
View file

@ -0,0 +1,29 @@
[CmdletBinding(SupportsShouldProcess)]param(
[Parameter(Mandatory)]
[string]$LocalPath,
[Parameter(Mandatory)]
[string]$GitOrigin,
[string]$Branch='HEAD'
)
$local:gitPath = Join-Path 'themes' 'plextheme' | Get-Path
function doGit { git "--git-dir=`"$(Join-Path $LocalPath '.git')`"" "--work-tree=`"$LocalPath`"" $args }
$local:savedErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = 'Stop'
$local:exists = Test-Path $LocalPath
try {
if( $exists ) {
# Update code from git repo
Write-Verbose "Pulling from [$GitOrigin] into [$LocalPath] on branch/tag '$Branch'..."
doGit fetch --quiet
} else {
git clone $GitOrigin $LocalPath
}
doGit checkout $Branch --quiet
if( $exists ) {
doGit status
}
} catch {
throw $_
} finally {
$ErrorActionPreference = $savedErrorActionPreference
}