Parse AddRoot hunk

andybalholm
Mar 30, 2023, 5:42 PM
TLR47XSA54QIJJVDDUFBPEVPWMG64BVI5QFVDPBFJD2LOGPXQQ3AC

Dependencies

  • [2] CSP3ROTU Better testing infrastructure
  • [3] 6GDPWAD2 Parse Unhashed and Contents of Change
  • [4] 7VEHGTEY Switch from reading text format to reading binary format.
  • [*] EVHNGDT7 parse FileAdd hunk
  • [*] PHRWK7NK Parse change headers
  • [*] 4JWXOJIP Parse dependencies

Change contents

  • edit in hunk.go at line 191
    [6.3441]
    [6.3441]
    case 11:
    return addRoot(data)
  • edit in hunk.go at line 228
    [6.4158]
    [6.4158]
    }
    type AddRoot struct {
    Name Atom
    Inode Atom
    }
    func (AddRoot) isHunk() {}
    func addRoot(data []byte) ([]byte, AddRoot, error) {
    var a AddRoot
    data, _, err := tuple(
    assign(&a.Name, atom),
    assign(&a.Inode, atom),
    )(data)
    return data, a, err
  • edit in change_test.go at line 15
    [2.1]
    [2.1]
    //go:embed testdata/DSPWN6DOSXQ3IIPW2JNOLFP32C7SQTSQZ7BBSEGA4UWNXQXNMS6AC.change
    var DSPWN6 []byte
    //go:embed testdata/MRE2H23UNRCHMZIKISVB4T7DTDDVVK7DCCSLFEMXOXLLQNQVELGAC.change
    var MRE2H2 []byte
  • edit in change_test.go at line 25
    [2.79]
    [2.79]
    text string
  • edit in change_test.go at line 108
    [3.437]
    [7.1094]
    {
    hash: "DSPWN6DOSXQ3IIPW2JNOLFP32C7SQTSQZ7BBSEGA4UWNXQXNMS6AC",
    data: DSPWN6,
    parsed: Change{
    Version: 6,
    Message: "",
    Timestamp: time.Date(2023, 3, 29, 23, 24, 28, 233348937, time.UTC),
    Authors: []map[string]string{},
    Dependencies: []Hash{},
    ExtraKnown: []Hash{},
    Metadata: []byte{},
    Changes: []Hunk{
    AddRoot{
    Name: NewVertex{
    UpContext: []Position{
    {
    Change: OptionalHash{true, Hash{}},
    Pos: 0,
    },
    },
    DownContext: []Position{},
    Flag: 17,
    Start: 0,
    End: 0,
    Inode: Position{
    Change: OptionalHash{true, Hash{}},
    Pos: 0,
    },
    },
    Inode: NewVertex{
    UpContext: []Position{
    {
    Change: OptionalHash{},
    Pos: 0,
    },
    },
    DownContext: []Position{},
    Flag: 17,
    Start: 1,
    End: 1,
    Inode: Position{
    Change: OptionalHash{true, Hash{}},
    Pos: 0,
    },
    },
    },
    },
    ContentsHash: mustHashFromBase32("QXZAPGWPXKVFMHB5UIIYKF4K2STXSWH3RPLXVTR5WR6HKSERFVOAC"),
    Contents: []byte{
    0xfa, 0x7b, 0xfe, 0x96, 0x61, 0x6e, 0x0a, 0xa1, 0x6b, 0x40, 0x73, 0xa6, 0x99, 0xf8, 0xbb, 0x8c,
    0x15, 0x35, 0xc9, 0x3f, 0x6f, 0xfc, 0x8f, 0x4b, 0x72, 0xd8, 0xa9, 0x1d, 0xd4, 0xde, 0x7f, 0x86,
    },
    },
    text: `message = ''
    timestamp = '2023-03-29T23:24:28.233348937Z'
    authors = []
    # Hunks
    1. Root add
    up 1.0, new 0:0`,
    },
  • edit in change.go at line 53
    [8.1701]
    [8.1701]
    }
    func mustHashFromBase32(b32 string) Hash {
    h, err := HashFromBase32(b32)
    if err != nil {
    panic(err)
    }
    return h
  • replacement in change.go at line 104
    [3.770][3.770:858]()
    err = json.Unmarshal(unhashed, &c.Unhashed)
    if err != nil {
    return Change{}, err
    [3.770]
    [3.858]
    if len(unhashed) > 0 {
    err = json.Unmarshal(unhashed, &c.Unhashed)
    if err != nil {
    return Change{}, fmt.Errorf("error parsing unhashed contents (%q): %w", unhashed, err)
    }
  • edit in .ignore at line 3
    [7.1921]
    sandbox