╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Events.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
770 const fetch_ssh_command = try std.fmt.allocPrint(allocator, "{s}{s} -o BatchMode=yes -o LogLevel=QUIET", .{ ssh, if (isLoopbackSshUrl(fetch_url)) loopback_opts else "" }); 771 defer allocator.free(fetch_ssh_command); 772 const push_ssh_command = try std.fmt.allocPrint(allocator, "{s}{s} -o BatchMode=yes -o LogLevel=QUIET", .{ ssh, if (isLoopbackSshUrl(push_url)) loopback_opts else "" }); 773 defer allocator.free(push_ssh_command); 774 const fetch_transport_opts: xit.net.Opts(repo_opts.ProgressCtx) = .{ .progress_ctx = .{ .message = &message }, .wire = .{ .ssh = .{ .command = fetch_ssh_command } } }; 775 const push_transport_opts: xit.net.Opts(repo_opts.ProgressCtx) = .{ .progress_ctx = .{ .message = &message }, .wire = .{ .ssh = .{ .command = push_ssh_command } } }; 776 777 const fetch_refspec = try std.fmt.allocPrint(allocator, "+refs/heads/{s}:refs/remotes/{s}/{s}", .{ evt.events_ref.name, remote_name, evt.events_ref.name }); 778 defer allocator.free(fetch_refspec); 779 var fetch_opts = fetch_transport_opts; 780 fetch_opts.refspecs = &.{fetch_refspec}; 781 message.clearRetainingCapacity(); 782 repo.fetch(io, allocator, remote_name, fetch_opts) catch |err| { 783 if (err == error.ServerReportedError and message.written().len != 0) return try allocator.dupe(u8, message.written()); 784 return err; 785 }; 786 787 const remote_ref: rf.Ref = .{ .kind = .{ .remote = remote_name }, .name = evt.events_ref.name }; 788 const local_oid = try repo.readRef(io, evt.events_ref); 789 const remote_oid = try repo.readRef(io, remote_ref); 790 if (local_oid == null and remote_oid == null) { 791 try evt.consume(.local, .repo, repo_kind, repo_opts, io, allocator, repo, evt.events_ref, &.{}); 792 return null; 793 } 794 if (remote_oid != null) try evt.mergeEvents(repo_kind, repo_opts, io, allocator, repo, remote_ref); 795 try evt.consume(.local, .repo, repo_kind, repo_opts, io, allocator, repo, evt.events_ref, &.{}); 796 797 const push_refspec = try std.fmt.allocPrint(allocator, "refs/heads/{s}:refs/heads/{s}", .{ evt.events_ref.name, evt.events_ref.name }); 798 defer allocator.free(push_refspec); 799 message.clearRetainingCapacity(); 800 repo.push(io, allocator, remote_name, push_refspec, false, push_transport_opts) catch |err| { 801 if (err == error.ServerReportedError and message.written().len != 0) return try allocator.dupe(u8, message.written()); 802 return err; 803 }; 804 message.clearRetainingCapacity(); 805 repo.fetch(io, allocator, remote_name, fetch_opts) catch |err| { 806 if (err == error.ServerReportedError and message.written().len != 0) return try allocator.dupe(u8, message.written()); 807 return err; 808 }; 809 }, 810 } 811 }, 812 } 813 return null; 814 } 815