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