param(
[string]$Repository = "target\benchmark-index-10000",
[int]$Files = 10000
)
$ErrorActionPreference = "Stop"
if ($Files -lt 1) {
throw "Files must be greater than zero"
}
$repo = [IO.Path]::GetFullPath($Repository)
if (Test-Path -LiteralPath $repo) {
throw "Fixture already exists: $repo"
}
git init -q $repo
if ($LASTEXITCODE -ne 0) {
throw "git init failed"
}
git -C $repo config user.name "Weavatrix Benchmark"
git -C $repo config user.email "benchmark@weavatrix.local"
$encoding = [Text.UTF8Encoding]::new($false)
for ($index = 0; $index -lt $Files; $index++) {
$name = "file-{0:D6}.txt" -f $index
[IO.File]::WriteAllText(
[IO.Path]::Combine($repo, $name),
"$index`n",
$encoding
)
}
git -C $repo add -A
git -C $repo commit -q -m "index fixture"
if ($LASTEXITCODE -ne 0) {
throw "fixture commit failed"
}
Write-Output $repo