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:
parent
aa44d120e4
commit
8a93a0f123
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"package": {
|
||||
"Condition": [],
|
||||
"Name": "GitHub"
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Get-Content
|
|
@ -5,7 +5,15 @@
|
|||
)
|
||||
$local:possibleValues = $fullValueSet
|
||||
if( $wordToComplete ) {
|
||||
$possibleValues = $possibleValues | Where-Object { $_ -match $wordToComplete }
|
||||
$possibleValues = $possibleValues |
|
||||
Where-Object { $_ -match $wordToComplete } |
|
||||
ForEach-Object {
|
||||
if( $_ -match ' ' ) {
|
||||
"'$_'"
|
||||
} else {
|
||||
$_
|
||||
}
|
||||
}
|
||||
if( -not $strict -and ($wordToComplete -notin $possibleValues) ) {
|
||||
$possibleValues = $( $wordToComplete; $possibleValues )
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ process {
|
|||
$outputFileName = Join-Path $OutputPath $outputFileName
|
||||
|
||||
if( (Test-Path $outputFileName) -and -not $Force) {
|
||||
throw "$OutputPath already exists"
|
||||
throw "$OutputFileName file already exists"
|
||||
}
|
||||
|
||||
Write-Verbose "About to start download from:`n`t$Url`n`tto`n`t$outputFileName`n"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
)
|
||||
|
||||
$local:EditCandidates = @('docker-compose.###','.base.docker-compose.###')
|
||||
$local:EditCandidates = @('docker-compose.###','.base.docker-compose.###','secrets.env')
|
||||
$local:EditBonus = @('Dockerfile', '.env', '*.env')
|
||||
$local:editFiles = @()
|
||||
foreach( $local:ext in @('.yml', '.yaml') ) {
|
||||
|
@ -15,7 +15,7 @@ foreach( $local:ext in @('.yml', '.yaml') ) {
|
|||
foreach( $local:path in $ProjectPath ) {
|
||||
$local:testPath = Join-Path $path $fileName
|
||||
if( $Force -or $(Test-Path $testPath) ) {
|
||||
$editFiles += $testPath
|
||||
$editFiles += $testPath | Get-Path
|
||||
$editFiles += Get-ChildItem $(Join-Path $path '*') -Include $EditBonus -Depth 1 |
|
||||
Select-Object -ExpandProperty FullName
|
||||
}
|
||||
|
@ -37,9 +37,17 @@ $AdditionalFiles = $AdditionalFiles | Where-Object { $_ } | ForEach-Object {
|
|||
|
||||
$local:FinalEditList = $editFiles | Where-Object {$_} | Sort-Object {
|
||||
$local:n = [System.IO.Path]::GetFileName($_)
|
||||
Join-Path [PSystem.IO.ath]::GetDirectoryName($_) "$(if( $n[0] -eq '.' ) { "9" } else { "1" })$n"
|
||||
$local:sorder = "$(
|
||||
if( $n[0] -eq '.' ) { "2" }
|
||||
elseif( $n -match 'docker-compose\.y' ) { "1" }
|
||||
else { "9" }
|
||||
)$n"
|
||||
Write-Verbose "sorder($n)=$sorder"
|
||||
$local:sorder = Join-Path $([System.IO.Path]::GetDirectoryName($_)) $sorder
|
||||
$sorder
|
||||
}
|
||||
$FinalEditList = (@() + $FinalEditList + @() + $AdditionalFiles) | Select-Object -Unique
|
||||
Write-Verbose "`$FinalEditList = `n$($FinalEditList | Out-String)"
|
||||
|
||||
Edit-TextFile $FinalEditList
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
$local:workTree = git worktree list --porcelain | Select-String worktree | ForEach-Object { $_ -split 'worktree ' } | Where-Object { $_ }
|
||||
Edit-TextFile $(Join-Path $workTree .gitignore)
|
|
@ -0,0 +1,11 @@
|
|||
[CmdletBinding()]param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$GitHubProject,
|
||||
[string]$tag='latest'
|
||||
)
|
||||
|
||||
Invoke-WebRequest https://github.com/$GitHubProject/releases/$tag -ErrorAction Stop |
|
||||
Select-Object -ExpandProperty Links |
|
||||
Where-Object title |
|
||||
Where-Object href -match 'tree/[^/]+$' |
|
||||
Select-Object -ExpandProperty title -First 1
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
$local:workTree = git worktree list --porcelain | Select-String worktree | ForEach-Object { $_ -split 'worktree ' } | Where-Object { $_ }
|
||||
Push-Location $workTree
|
||||
$null = git reset HEAD
|
||||
$null = git rm --cached -r .
|
||||
$null = git add .
|
||||
git status
|
||||
Pop-Location
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"package": {
|
||||
"Condition": [
|
||||
{
|
||||
"custom": "Get-Command git -Type Application",
|
||||
"System": null,
|
||||
"Hostname": null,
|
||||
"Username": null,
|
||||
"Logic": 0
|
||||
}
|
||||
],
|
||||
"Name": "git"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue