╭ changed ─────────╮ │src/event/Fork.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────╮ │ 5 │ │ 6 user_id: []const u8, │ │ 7 repo_id: []const u8, │ │ 8 -target: []const u8, │ │ 9 -source_oid: ?[]const u8 = null, │ │ 8 │ │ 9 // what the db stores: the event's data plus the commit-derived fields│ │10 pub const Record = struct { │ ╰──────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │24 fn validate(record: Record) !void { │ │25 if (record.event.user_id.len != evt.event_id_size) return error.InvalidUserId; │ │26 if (record.event.repo_id.len != evt.event_id_size) return error.InvalidRepoId; │ │29 - if (!xit.ref.validateName(record.event.target)) return error.InvalidTarget; │ │30 - if (record.event.source_oid) |oid| { │ │31 - if (oid.len == 0 or oid.len % 2 != 0) return error.InvalidSourceOid; │ │32 - for (oid) |c| { │ │33 - if (!std.ascii.isDigit(c) and !(c >= 'a' and c <= 'f')) return error.InvalidSourceOid;│ │34 - } │ │35 - } │ │27 } │ │28 │ │29 pub fn consume( │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │57 if (!record.removed) try validate(record); │ │58 │ │59 if (existing_maybe) |existing| { │ │60 + if (!std.mem.eql(u8, existing.event.user_id, record.event.user_id) or │ │61 + !std.mem.eql(u8, existing.event.repo_id, record.event.repo_id)) return error.ForkChanged;│ │62 record.created_order = existing.created_order; │ │63 if (!existing.removed) { │ │64 const order_key = evt.orderKeyDesc(existing.created_order, event_id); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯