fix(projects): same project text on every OS; compare stored CRLF versions line-end-insensitively
Project text was indented with Environment.NewLine, so the same project read as CRLF text on Windows and LF text on the Linux server and its content hash differed. A Windows desktop pushing to a Linux server got spurious Merge and External versions, Modified/Behind states with no edits, empty commits, and renders and sends taken for other settings. Every build now writes the project JSON with LF (ProjectJson and IndentedJson). Versions already stored keep their CRLF text and hash, so SameChoices reads CRLF as LF (lossless: raw line ends are JSON whitespace) and the places that ask whether a text is a given version use the new ProjectContent.MatchesHash, true for the hash of the LF or the CRLF form. Integrity checks of stored and pushed versions stay exact. Tests pin the LF default hash, cover both comparisons both ways, and push versions with the other OS's line ends to an archive home and into a workspace: no outside change, in sync, nothing to commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
863c6cf27b
commit
787f030060
15 files changed
+174
-25
No files matched your search
@@ -118,6 +118,30 @@ public abstract class WorkspaceMergeTests(TestContext context) : DatabaseTest(co
|
||||
Assert.Null(await sync.CommitAsync(id, cancellationToken: fx.Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ABaseSavedWithTheOtherOsLineEndsReadsAsTheWorkingState()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
Assert.True(fx.Frames.All(f => f.Sha256 is { Length: 64 }));
|
||||
var projects = fx.Archive.Service.Projects;
|
||||
var main = await projects.MainAsync(fx.Sequence.Id, fx.Ct);
|
||||
// The head a build before stored on the other OS (CRLF where this build writes LF, and the reverse on Linux).
|
||||
var foreign = ProjectServiceTests.Foreign(ProjectServiceTests.Draft(await projects.HeadAsync(main.Id, fx.Ct),
|
||||
new ProjectSettings { ExcludedFrames = [1], HeroFrame = 3 }, fx.Frames));
|
||||
Assert.Equal(PushOutcome.Stored, (await projects.PushAsync(main.Id, foreign, fx.Ct)).Outcome);
|
||||
|
||||
var (_, sync) = fx.Workspace();
|
||||
var project = await fx.CheckoutAsync(sync);
|
||||
var id = project.ProjectId;
|
||||
Assert.Equal(foreign.ContentHash, project.ReadBundle().Workspace!.Base!.ContentHash);
|
||||
Assert.SequenceEqual([1], (await sync.OpenAsync(id, fx.Ct)).Working.ExcludedFrames);
|
||||
|
||||
// Nothing edited here: in step with its base, and nothing to save.
|
||||
Assert.Equal(WorkspaceState.InSync, (await sync.StatusAsync(id, fx.Home, fx.Ct)).State);
|
||||
Assert.Null(await sync.CommitAsync(id, cancellationToken: fx.Ct));
|
||||
Assert.Equal(foreign.Id, (await fx.Home.HeadAsync(id, fx.Ct)).Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ABaseNamingAPhotoByItsHashReadsAsTheWorkingStateOnMediaThatHaveNotLearntIt()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user