Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/browseros/tools/bdev/internal/patch/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func signature(p FilePatch) string {
return "delete:" + NormalizeChromiumPath(p.Path)
case p.IsPureRename():
return strings.Join([]string{"rename", NormalizeChromiumPath(p.OldPath), NormalizeChromiumPath(p.Path)}, ":")
case p.Op == OpBinary && len(p.Content) == 0:
case p.Op == OpBinary:
return "binary:" + NormalizeChromiumPath(p.Path)
default:
lines := strings.Split(strings.ReplaceAll(string(p.Content), "\r\n", "\n"), "\n")
Expand Down
41 changes: 41 additions & 0 deletions packages/browseros/tools/bdev/internal/patch/patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,47 @@ func TestBuildRangePatchSetUsesLatestBaseScopedPatch(t *testing.T) {
}
}

func TestSignatureForBinaryPatchWithContent(t *testing.T) {
// Create a binary patch with content
p := FilePatch{
Path: "chrome/binary.bin",
Op: OpBinary,
IsBinary: true,
Content: []byte("GIT binary patch\nliteral 5\nabcde\n"),
}

sig := signature(p)

// The signature should handle binary patches with content
// With our fix, it should always use "binary:" prefix for OpBinary
if !strings.HasPrefix(sig, "binary:") {
t.Errorf("Expected signature for binary patch with content to start with 'binary:', got %q", sig)
}
// Check the path is included
expectedPath := "binary:chrome/binary.bin"
if sig != expectedPath {
t.Errorf("Expected signature %q, got %q", expectedPath, sig)
}
}

func TestSignatureForBinaryPatchWithoutContent(t *testing.T) {
// Create a binary patch without content
p := FilePatch{
Path: "chrome/empty.bin",
Op: OpBinary,
IsBinary: true,
Content: []byte{},
}

sig := signature(p)

// Should still use "binary:" prefix
expectedPath := "binary:chrome/empty.bin"
if sig != expectedPath {
t.Errorf("Expected signature %q, got %q", expectedPath, sig)
}
}

func runGit(t *testing.T, dir string, args ...string) {
t.Helper()
cmd := exec.Command("git", args...)
Expand Down
Loading