Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1c5648c5c | ||
|
|
ad3b6a2297 | ||
|
|
8d6437800c |
No files matched your search
@@ -2,6 +2,7 @@ import io
|
|||||||
import json
|
import json
|
||||||
import unittest
|
import unittest
|
||||||
import urllib.error
|
import urllib.error
|
||||||
|
from email.message import Message
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from shared_backend.authclient import (
|
from shared_backend.authclient import (
|
||||||
@@ -37,7 +38,7 @@ def _fake_http_error(status: int, payload: dict) -> urllib.error.HTTPError:
|
|||||||
url="http://authguard.example/api/session/validate",
|
url="http://authguard.example/api/session/validate",
|
||||||
code=status,
|
code=status,
|
||||||
msg="error",
|
msg="error",
|
||||||
hdrs=None,
|
hdrs=Message(),
|
||||||
fp=io.BytesIO(body),
|
fp=io.BytesIO(body),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -12,20 +12,44 @@ if ($Push -and -not $Commit) {
|
|||||||
throw 'The -Push switch requires -Commit so that only generated synchronization changes are pushed.'
|
throw 'The -Push switch requires -Commit so that only generated synchronization changes are pushed.'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function New-ConsumerProject {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Path,
|
||||||
|
|
||||||
|
[string]$Destination = 'shared'
|
||||||
|
)
|
||||||
|
|
||||||
|
return [pscustomobject]@{ Path = $Path; Destination = $Destination }
|
||||||
|
}
|
||||||
|
|
||||||
|
# Destination defaults to 'shared' (the snapshot folder name most consumers
|
||||||
|
# use). The engine/media-backend family below mounts the same snapshot at
|
||||||
|
# 'engine' instead - historically a git submodule, converted to this same
|
||||||
|
# vendored-copy pattern for consistency and to drop the private-submodule
|
||||||
|
# checkout auth dependency in CI.
|
||||||
$consumerProjects = @(
|
$consumerProjects = @(
|
||||||
'Original/AutoCode',
|
New-ConsumerProject 'Original/MediaDesktop'
|
||||||
'Original/SimpleCollection',
|
New-ConsumerProject 'Original/AutoCode'
|
||||||
'Original/CollabTable',
|
New-ConsumerProject 'Original/SimpleCollection'
|
||||||
'Original/GameStream',
|
New-ConsumerProject 'Original/CollabTable'
|
||||||
'Original/SyncServer',
|
New-ConsumerProject 'Original/GameStream'
|
||||||
'Original/UnraidMonitor',
|
New-ConsumerProject 'Original/SyncServer'
|
||||||
'Original/PubliSafe',
|
New-ConsumerProject 'Original/UnraidMonitor'
|
||||||
'Forks/Bitmagnet',
|
New-ConsumerProject 'Original/PubliSafe'
|
||||||
'Forks/Heretic',
|
New-ConsumerProject 'Forks/Bitmagnet'
|
||||||
'Original/InfiniteVideo',
|
New-ConsumerProject 'Forks/Heretic'
|
||||||
'Forks/MegaBasterd',
|
New-ConsumerProject 'Original/InfiniteVideo'
|
||||||
'Forks/HordeWorker',
|
New-ConsumerProject 'Forks/MegaBasterd'
|
||||||
'Original/OutdoorGames'
|
New-ConsumerProject 'Forks/HordeWorker'
|
||||||
|
New-ConsumerProject 'Original/OutdoorGames'
|
||||||
|
New-ConsumerProject 'Original/KioskDisplay' -Destination 'engine'
|
||||||
|
New-ConsumerProject 'Original/MediaAnalyzer' -Destination 'engine'
|
||||||
|
New-ConsumerProject 'Original/MediaTools' -Destination 'engine'
|
||||||
|
New-ConsumerProject 'Original/MediaViewer' -Destination 'engine'
|
||||||
|
New-ConsumerProject 'Central/MediaServant' -Destination 'engine'
|
||||||
|
New-ConsumerProject 'Central/ModerationHub' -Destination 'engine'
|
||||||
|
New-ConsumerProject 'Central/ProjectConfigurator' -Destination 'engine'
|
||||||
)
|
)
|
||||||
|
|
||||||
function Invoke-GitText {
|
function Invoke-GitText {
|
||||||
@@ -216,7 +240,9 @@ Write-Host "Synchronizing $($sourceFiles.Count) tracked shared files from $sourc
|
|||||||
|
|
||||||
$failures = New-Object 'System.Collections.Generic.List[string]'
|
$failures = New-Object 'System.Collections.Generic.List[string]'
|
||||||
|
|
||||||
foreach ($relativeProject in $consumerProjects) {
|
foreach ($consumerProject in $consumerProjects) {
|
||||||
|
$relativeProject = $consumerProject.Path
|
||||||
|
$destination = $consumerProject.Destination
|
||||||
$projectRoot = Join-Path $workspaceRoot ($relativeProject -replace '/', '\')
|
$projectRoot = Join-Path $workspaceRoot ($relativeProject -replace '/', '\')
|
||||||
if (-not (Test-Path -LiteralPath $projectRoot -PathType Container)) {
|
if (-not (Test-Path -LiteralPath $projectRoot -PathType Container)) {
|
||||||
$failures.Add("${relativeProject}: project directory not found")
|
$failures.Add("${relativeProject}: project directory not found")
|
||||||
@@ -225,19 +251,20 @@ foreach ($relativeProject in $consumerProjects) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$projectRoot = Resolve-FullPath $projectRoot
|
$projectRoot = Resolve-FullPath $projectRoot
|
||||||
$destinationRoot = Join-Path $projectRoot 'shared'
|
$destinationRoot = Join-Path $projectRoot $destination
|
||||||
|
$isLegacyEligible = $destination -eq 'shared'
|
||||||
$legacyDirectoryName = ('Shared' + 'Code')
|
$legacyDirectoryName = ('Shared' + 'Code')
|
||||||
$projectDirectories = @(Get-ChildItem -LiteralPath $projectRoot -Directory -Force)
|
$projectDirectories = @(Get-ChildItem -LiteralPath $projectRoot -Directory -Force)
|
||||||
$destinationEntry = $projectDirectories | Where-Object { $_.Name -ceq 'shared' }
|
$destinationEntry = $projectDirectories | Where-Object { $_.Name -ceq $destination }
|
||||||
$legacyEntry = $projectDirectories | Where-Object { $_.Name -ceq $legacyDirectoryName }
|
$legacyEntry = if ($isLegacyEligible) { $projectDirectories | Where-Object { $_.Name -ceq $legacyDirectoryName } } else { $null }
|
||||||
if ($null -ne $destinationEntry -and $null -ne $legacyEntry) {
|
if ($null -ne $destinationEntry -and $null -ne $legacyEntry) {
|
||||||
throw "Both shared and the legacy shared snapshot directory exist. Remove the legacy directory before synchronizing."
|
throw "Both $destination and the legacy shared snapshot directory exist. Remove the legacy directory before synchronizing."
|
||||||
}
|
}
|
||||||
|
|
||||||
$dirtyshared = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('status', '--porcelain', '--', 'shared'))
|
$dirtyDestination = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('status', '--porcelain', '--', $destination))
|
||||||
$dirtyLegacy = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('status', '--porcelain', '--', $legacyDirectoryName))
|
$dirtyLegacy = if ($isLegacyEligible) { @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('status', '--porcelain', '--', $legacyDirectoryName)) } else { @() }
|
||||||
if (($dirtyshared.Count -gt 0 -or $dirtyLegacy.Count -gt 0) -and -not $Force) {
|
if (($dirtyDestination.Count -gt 0 -or $dirtyLegacy.Count -gt 0) -and -not $Force) {
|
||||||
throw "shared has local changes. Commit them or rerun with -Force."
|
throw "$destination has local changes. Commit them or rerun with -Force."
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($null -ne $legacyEntry) {
|
if ($null -ne $legacyEntry) {
|
||||||
@@ -248,11 +275,11 @@ foreach ($relativeProject in $consumerProjects) {
|
|||||||
|
|
||||||
New-Item -ItemType Directory -Force -Path $destinationRoot | Out-Null
|
New-Item -ItemType Directory -Force -Path $destinationRoot | Out-Null
|
||||||
|
|
||||||
$existingSharedFiles = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('ls-files', '--', 'shared') | Where-Object { $_ -like 'shared/*' })
|
$existingDestinationFiles = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('ls-files', '--', $destination) | Where-Object { $_ -like "$destination/*" })
|
||||||
foreach ($existingSharedFile in $existingSharedFiles) {
|
foreach ($existingDestinationFile in $existingDestinationFiles) {
|
||||||
$relativeSharedFile = $existingSharedFile.Substring('shared/'.Length).Replace('\', '/')
|
$relativeDestinationFile = $existingDestinationFile.Substring("$destination/".Length).Replace('\', '/')
|
||||||
if (-not $sourceFileSet.ContainsKey($relativeSharedFile)) {
|
if (-not $sourceFileSet.ContainsKey($relativeDestinationFile)) {
|
||||||
$stalePath = Join-Path $destinationRoot ($relativeSharedFile -replace '/', '\')
|
$stalePath = Join-Path $destinationRoot ($relativeDestinationFile -replace '/', '\')
|
||||||
if (Test-Path -LiteralPath $stalePath -PathType Leaf) {
|
if (Test-Path -LiteralPath $stalePath -PathType Leaf) {
|
||||||
Remove-Item -LiteralPath $stalePath -Force
|
Remove-Item -LiteralPath $stalePath -Force
|
||||||
}
|
}
|
||||||
@@ -315,15 +342,15 @@ foreach ($relativeProject in $consumerProjects) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$null = Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('add', '--', 'shared')
|
$null = Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('add', '--', $destination)
|
||||||
foreach ($lockFile in $lockFiles) {
|
foreach ($lockFile in $lockFiles) {
|
||||||
$null = Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('add', '--', $lockFile)
|
$null = Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('add', '--', $lockFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
$targetPaths = @('shared') + $lockFiles
|
$targetPaths = @($destination) + $lockFiles
|
||||||
$stagedChanges = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments (@('diff', '--cached', '--name-only', '--') + $targetPaths))
|
$stagedChanges = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments (@('diff', '--cached', '--name-only', '--') + $targetPaths))
|
||||||
if ($Commit -and $stagedChanges.Count -gt 0) {
|
if ($Commit -and $stagedChanges.Count -gt 0) {
|
||||||
$commitMessage = "Sync shared snapshot from $sourceCommit"
|
$commitMessage = "Sync $destination snapshot from $sourceCommit"
|
||||||
$commitArguments = @('commit', '--only', '-m', $commitMessage, '--') + $targetPaths
|
$commitArguments = @('commit', '--only', '-m', $commitMessage, '--') + $targetPaths
|
||||||
$commitOutput = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments $commitArguments)
|
$commitOutput = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments $commitArguments)
|
||||||
$commitOutput | ForEach-Object { Write-Host " $_" }
|
$commitOutput | ForEach-Object { Write-Host " $_" }
|
||||||
|
|||||||
Reference in new issue
Block a user