╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ ui.zig ───────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
116 .event = .{ .issue = .{ .title = "sync", .description = "", .tags = "" } }, 117 }}); 118 } 119 120 try std.testing.expectEqual(null, try Events.sync(io, allocator, .{ .path = local_path, .repo_kind = .git })); 121 { 122 var local = try Repo.open(io, allocator, .{ .path = local_path }); 123 defer local.deinit(io, allocator); 124 const id = [_]u8{2} ** evt.event_id_size; 125 try evt.consume(.repo, .git, .{}, io, allocator, &local, evt.events_ref, &.{.{ 126 .id = std.fmt.bytesToHex(id, .lower), 127 .author = .{ .name = "haxy", .email = "user@haxy" }, 128 .event = .{ .issue = .{ .title = "local", .description = "", .tags = "" } }, 129 }}); 130 } 131 { 132 var remote = try RemoteRepo.open(io, allocator, .{ .path = remote_path }); 133 defer remote.deinit(io, allocator); 134 const id = [_]u8{3} ** evt.event_id_size; 135 try evt.consume(.repo, .git, .{}, io, allocator, &remote, evt.events_ref, &.{.{ 136 .id = std.fmt.bytesToHex(id, .lower), 137 .author = .{ .name = "haxy", .email = "user@haxy" }, 138 .event = .{ .issue = .{ .title = "remote", .description = "", .tags = "" } }, 139 }}); 140 } 141 try std.testing.expectEqual(null, try Events.sync(io, allocator, .{ .path = local_path, .repo_kind = .git })); 142 { 143 var local = try Repo.open(io, allocator, .{ .path = local_path }); 144 defer local.deinit(io, allocator); 145 try local.removeBranch(io, .{ .name = evt.events_ref.name }); 146 try evt.consume(.repo, .git, .{}, io, allocator, &local, evt.events_ref, &.{}); 147 } 148 try std.testing.expectEqual(null, try Events.sync(io, allocator, .{ .path = local_path, .repo_kind = .git })); 149 150 var local = try Repo.open(io, allocator, .{ .path = local_path }); 151 defer local.deinit(io, allocator); 152 var head_buffer: [xit.ref.MAX_REF_CONTENT_SIZE]u8 = undefined; 153 const head = try local.head(io, &head_buffer); 154 switch (head) { 155 .ref => |ref| try std.testing.expectEqualStrings("master", ref.name), 156 .oid => return error.TestExpectedEqual, 157 } 158 const kept = try local.core.work_dir.openFile(io, "keep.txt", .{}); 159 kept.close(io); 160 const local_tip = (try local.readRef(io, evt.events_ref)) orelse return error.TestExpectedEqual; 161 162 var remote = try RemoteRepo.open(io, allocator, .{ .path = remote_path }); 163 defer remote.deinit(io, allocator); 164 const remote_tip = (try remote.readRef(io, evt.events_ref)) orelse return error.TestExpectedEqual; 165 try std.testing.expectEqualStrings(&local_tip, &remote_tip); 166 167 var start_oids = [_][local_tip.len]u8{local_tip}; 168 var commit_iter = try local.log(io, allocator, &start_oids); 169 defer commit_iter.deinit(); 170 var merge_commit = (try commit_iter.next(allocator)) orelse return error.TestExpectedEqual; 171 defer merge_commit.deinit(); 172 const parent_oids = merge_commit.content.commit.metadata.parent_oids orelse return error.TestExpectedEqual; 173 try std.testing.expectEqual(2, parent_oids.len); 174 175 var arena = std.heap.ArenaAllocator.init(allocator); 176 defer arena.deinit(); 177 const status = try Events.Header.local(.git, .{}, arena.allocator(), &local, io, null); 178 try std.testing.expectEqualStrings("nothing to sync", status.sync_status orelse return error.TestExpectedEqual); 179 } 180