Skip to content

Commit 9ba0610

Browse files
committed
Add multiple proto "entry points" to MutagenSdk
- Adds support for an array of protobuf "entry points" - Refactors file modification/writing to be more efficient and to not include an unnecessary byte order mark and two trailing new lines
1 parent 0fefe8a commit 9ba0610

25 files changed

+97
-61
lines changed

MutagenSdk/Proto/filesystem/behavior/probe_mode.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/selection/selection.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/service/daemon/daemon.proto

+53
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/service/synchronization/synchronization.proto

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/compression/algorithm.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/configuration.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/core/change.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/core/conflict.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/core/entry.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/core/ignore/ignore_vcs_mode.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/core/ignore/syntax.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/core/mode.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/core/permissions_mode.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/core/problem.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/core/symbolic_link_mode.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/hashing/algorithm.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/rsync/receive.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/scan_mode.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/session.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/stage_mode.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/state.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/version.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/synchronization/watch_mode.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Proto/url/url.proto

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MutagenSdk/Update-Proto.ps1

+20-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ $ErrorActionPreference = "Stop"
88

99
$repo = "mutagen-io/mutagen"
1010
$protoPrefix = "pkg"
11-
$entryFile = "service\synchronization\synchronization.proto"
11+
$entryFiles = @(
12+
"service/synchronization/synchronization.proto",
13+
"service/daemon/daemon.proto"
14+
)
1215

1316
$outputNamespace = "Coder.Desktop.MutagenSdk.Proto"
1417
$outputDir = "MutagenSdk\Proto"
@@ -53,15 +56,8 @@ $licenseContent = Get-Content (Join-Path $cloneDir "LICENSE")
5356
$mitStartIndex = $licenseContent.IndexOf("MIT License")
5457
$licenseHeader = ($licenseContent[$mitStartIndex..($licenseContent.Length - 1)] | ForEach-Object { (" * " + $_).TrimEnd() }) -join "`n"
5558

56-
$entryFilePath = Join-Path $cloneDir (Join-Path $protoPrefix $entryFile)
57-
if (-not (Test-Path $entryFilePath)) {
58-
throw "Failed to find $entryFilePath in mutagen repo"
59-
}
60-
6159
# Map of src (in the mutagen repo) to dst (within the $outputDir).
62-
$filesToCopy = @{
63-
$entryFilePath = $entryFile
64-
}
60+
$filesToCopy = @{}
6561

6662
function Add-ImportedFiles([string] $path) {
6763
$content = Get-Content $path
@@ -88,7 +84,14 @@ function Add-ImportedFiles([string] $path) {
8884
}
8985
}
9086

91-
Add-ImportedFiles $entryFilePath
87+
foreach ($entryFile in $entryFiles) {
88+
$entryFilePath = Join-Path $cloneDir (Join-Path $protoPrefix $entryFile)
89+
if (-not (Test-Path $entryFilePath)) {
90+
throw "Failed to find $entryFilePath in mutagen repo"
91+
}
92+
$filesToCopy[$entryFilePath] = $entryFile
93+
Add-ImportedFiles $entryFilePath
94+
}
9295

9396
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
9497
Push-Location $repoRoot
@@ -105,7 +108,6 @@ try {
105108
if (-not (Test-Path $destDir)) {
106109
New-Item -ItemType Directory -Path $destDir -Force
107110
}
108-
Copy-Item -Force $filePath $dstPath
109111

110112
# Determine the license header.
111113
$fileHeader = "/*`n" +
@@ -125,14 +127,18 @@ try {
125127
$csharpNamespace += ".$csharpNamespaceSuffix"
126128
}
127129

128-
# Add the csharp_namespace declaration.
129-
$content = Get-Content $dstPath -Raw
130+
# Add the license header and csharp_namespace declaration.
131+
$content = Get-Content $filePath -Raw
130132
$content = $fileHeader + $content
131133
$content = $content -replace '(?m)^(package .*?;)', "`$1`noption csharp_namespace = `"$csharpNamespace`";"
132134

133135
# Replace all LF with CRLF to avoid spurious diffs in git.
134136
$content = $content -replace "(?<!`r)`n", "`r`n"
135-
Set-Content -Path $dstPath -Value $content -Encoding UTF8
137+
138+
# Instead of using Set-Content, we use System.IO.File.WriteAllText
139+
# instead to avoid a byte order mark at the beginning of the file, as
140+
# well as an extra newline at the end of the file.
141+
[System.IO.File]::WriteAllText($dstPath, $content, [System.Text.UTF8Encoding]::new($false))
136142
}
137143
}
138144
finally {

0 commit comments

Comments
 (0)