╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Events.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
920 defer allocator.free(fetch_ssh_command); 921 const push_ssh_command = try allocator.print("{s}{s} -o BatchMode=yes -o LogLevel=QUIET", .{ ssh, if (isLoopbackSshUrl(push_url)) loopback_opts else "" }); 922 defer allocator.free(push_ssh_command); 923 const fetch_transport_opts: xit.net.Opts(repo_opts.ProgressCtx) = .{ .progress_ctx = .{ .message = &message }, .wire = .{ .ssh = .{ .command = fetch_ssh_command } } }; 924 const push_transport_opts: xit.net.Opts(repo_opts.ProgressCtx) = .{ .progress_ctx = .{ .message = &message }, .wire = .{ .ssh = .{ .command = push_ssh_command } } }; 925 926 const fetch_refspec = try allocator.print("+refs/heads/{s}:refs/remotes/{s}/{s}", .{ evt.events_ref.name, remote_name, evt.events_ref.name }); 927 defer allocator.free(fetch_refspec); 928 var fetch_opts = fetch_transport_opts; 929 fetch_opts.refspecs = &.{fetch_refspec}; 930 message.clearRetainingCapacity(); 931 repo.fetch(io, allocator, remote_name, fetch_opts) catch |err| { 932 if (err == error.ServerReportedError and message.written().len != 0) return try allocator.dupe(u8, message.written()); 933 return err; 934 }; 935 936 const remote_ref: rf.Ref = .{ .kind = .{ .remote = remote_name }, .name = evt.events_ref.name }; 937 const local_oid = try repo.readRef(io, evt.events_ref); 938 const remote_oid = try repo.readRef(io, remote_ref); 939 if (local_oid == null and remote_oid == null) { 940 try evt.consume(.local, .repo, repo_kind, repo_opts, io, allocator, repo, evt.events_ref, &.{}); 941 return null; 942 } 943 if (remote_oid != null) try evt.mergeEvents(repo_kind, repo_opts, io, allocator, repo, remote_ref); 944 try evt.consume(.local, .repo, repo_kind, repo_opts, io, allocator, repo, evt.events_ref, &.{}); 945 946 const push_refspec = try allocator.print("refs/heads/{s}:refs/heads/{s}", .{ evt.events_ref.name, evt.events_ref.name }); 947 defer allocator.free(push_refspec); 948 message.clearRetainingCapacity(); 949 repo.push(io, allocator, remote_name, push_refspec, false, push_transport_opts) catch |err| { 950 if (err == error.ServerReportedError and message.written().len != 0) return try allocator.dupe(u8, message.written()); 951 return err; 952 }; 953 message.clearRetainingCapacity(); 954 repo.fetch(io, allocator, remote_name, fetch_opts) catch |err| { 955 if (err == error.ServerReportedError and message.written().len != 0) return try allocator.dupe(u8, message.written()); 956 return err; 957 }; 958 }, 959 } 960 }, 961 } 962 return null; 963 } 964