Parse Unhashed and Contents of Change

andybalholm
Mar 29, 2023, 10:31 PM
6GDPWAD2BSPC6EDH43HDTFRJ2QCDBPE3OK4KXFVYK23BLCAWWB3QC

Dependencies

  • [2] EVHNGDT7 parse FileAdd hunk
  • [3] 4JWXOJIP Parse dependencies
  • [4] 7VEHGTEY Switch from reading text format to reading binary format.
  • [*] PHRWK7NK Parse change headers

Change contents

  • edit in change_test.go at line 82
    [2.6367]
    [6.1094]
    Unhashed: map[string]any{
    "signature": "4cKLG1A2wd3pp6hBMaceFCGo8ADhUaDNz31MJeZxNFYnBf8yPepXfgor9o78y88ComC3b1YzDccucDbPbez9Ppxe",
    },
    Contents: []byte{
    0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x01,
    0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x54, 0x46, 0x2d, 0x38, 0x00, 0x00, 0x68,
    0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x0a, 0x00,
    },
  • edit in change.go at line 7
    [3.793]
    [3.793]
    "encoding/json"
  • edit in change.go at line 26
    [2.6408]
    [3.1181]
    Unhashed any
    Contents []byte
  • replacement in change.go at line 90
    [3.1816][3.1816:1848]()
    // TODO: unhashed and contents
    [3.1816]
    [3.1848]
    if off.ContentsOffset > off.UnhashedOffset {
    zr.Reset(bytes.NewReader(data[off.UnhashedOffset:off.ContentsOffset]))
    unhashed, err := io.ReadAll(zr)
    if err != nil {
    return Change{}, fmt.Errorf("error getting the 'unhashed' data chunk from the change: %w", err)
    }
    err = json.Unmarshal(unhashed, &c.Unhashed)
    if err != nil {
    return Change{}, err
    }
    }
    if int(off.ContentsOffset) < len(data) {
    zr.Reset(bytes.NewReader(data[off.ContentsOffset:]))
    c.Contents, err = io.ReadAll(zr)
    if err != nil {
    return Change{}, fmt.Errorf("error getting the 'contents' data chunk from the change: %w", err)
    }
    }