Artifact 5051fa33496a5eaf6e6102b442391cb6f280d265eea3e9b1f228a083d5c6a88a:
- File
internal/xfer/example_test.go
— part of check-in
[4082bffaa5]
at
2026-04-26 15:00:28
on branch trunk
— fix(xfer): always emit project code on push/pull cards (#12)
The encoder emitted bare 'push\n' / 'pull\n' cards in code paths where the project code wasn't passed explicitly. The upstream Fossil C server's xfer parser requires at least the project code on push and both project + server codes on pull, rejecting 0-arg cards. This broke libfossil <-> fossil interop on the first sync round.
Make the project code a required parameter on the encoder and update call sites to thread it through. The libfossil server-side decoder is tightened to match — it previously accepted 0-arg cards, which masked the encoder bug during Go-to-Go testing. (user: [email protected], size: 758) [annotate] [blame] [check-ins using]
package xfer_test import ( "fmt" "github.com/danmestas/libfossil/internal/xfer" ) func ExampleMessage_Encode() { msg := &xfer.Message{ Cards: []xfer.Card{ &xfer.PushCard{ProjectCode: "abc123"}, &xfer.PullCard{ProjectCode: "abc123", ServerCode: "def456"}, &xfer.IGotCard{UUID: "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"}, }, } wire, err := msg.Encode() if err != nil { fmt.Println("error:", err) return } // Wire format is zlib-compressed xfer cards. fmt.Printf("compressed: %v\n", len(wire) > 0) // Decode round-trips back to a Message. decoded, err := xfer.Decode(wire) if err != nil { fmt.Println("error:", err) return } fmt.Printf("cards: %d\n", len(decoded.Cards)) // Output: // compressed: true // cards: 3 }