╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Events.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
841 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 "" }); 842 defer allocator.free(fetch_ssh_command); 843 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 "" }); 844 defer allocator.free(push_ssh_command); 845 const fetch_transport_opts: xit.net.Opts(repo_opts.ProgressCtx) = .{ .progress_ctx = .{ .message = &message }, .wire = .{ .ssh = .{ .command = fetch_ssh_command } } }; 846 const push_transport_opts: xit.net.Opts(repo_opts.ProgressCtx) = .{ .progress_ctx = .{ .message = &message }, .wire = .{ .ssh = .{ .command = push_ssh_command } } }; 847 848 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 }); 849 defer allocator.free(fetch_refspec); 850 var fetch_opts = fetch_transport_opts; 851 fetch_opts.refspecs = &.{fetch_refspec}; 852 message.clearRetainingCapacity(); 853 repo.fetch(io, allocator, remote_name, fetch_opts) catch |err| { 854 if (err == error.ServerReportedError and message.written().len != 0) return try allocator.dupe(u8, message.written()); 855 return err; 856 }; 857 858 const remote_ref: rf.Ref = .{ .kind = .{ .remote = remote_name }, .name = evt.events_ref.name }; 859 const local_oid = try repo.readRef(io, evt.events_ref); 860 const remote_oid = try repo.readRef(io, remote_ref); 861 if (local_oid == null and remote_oid == null) { 862 try evt.consume(.local, .repo, repo_kind, repo_opts, io, allocator, repo, evt.events_ref, &.{}); 863 return null; 864 } 865 if (remote_oid != null) try evt.mergeEvents(repo_kind, repo_opts, io, allocator, repo, remote_ref); 866 try evt.consume(.local, .repo, repo_kind, repo_opts, io, allocator, repo, evt.events_ref, &.{}); 867 868 const push_refspec = try std.fmt.allocPrint(allocator, "refs/heads/{s}:refs/heads/{s}", .{ evt.events_ref.name, evt.events_ref.name }); 869 defer allocator.free(push_refspec); 870 message.clearRetainingCapacity(); 871 repo.push(io, allocator, remote_name, push_refspec, false, push_transport_opts) catch |err| { 872 if (err == error.ServerReportedError and message.written().len != 0) return try allocator.dupe(u8, message.written()); 873 return err; 874 }; 875 message.clearRetainingCapacity(); 876 repo.fetch(io, allocator, remote_name, fetch_opts) catch |err| { 877 if (err == error.ServerReportedError and message.written().len != 0) return try allocator.dupe(u8, message.written()); 878 return err; 879 }; 880 }, 881 } 882 }, 883 } 884 return null; 885 } 886