╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ try.zig ──────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
658 const word = scatter_words[w % scatter_words.len]; 659 const len = writer.written().len - start; 660 if (len >= target or len + 1 + word.len > 120) break; 661 if (len == 0) 662 try writer.writer.print("{s}", .{word}) 663 else 664 try writer.writer.print(" {s}", .{word}); 665 } 666 try writer.writer.writeByte('\n'); 667 } 668 try file.writeStreamingAll(io, writer.written()); 669 } 670 671 // tag the current HEAD as the next sequential version: v1, v2, and so on 672 fn addNextTag(repo: *rp.Repo(.xit, .{}), io: std.Io, allocator: std.mem.Allocator, n: *usize) !void { 673 var buf: [16]u8 = undefined; 674 const name = try std.fmt.bufPrint(&buf, "v{d}", .{n.*}); 675 _ = try repo.addTag(io, allocator, .{ .name = name }); 676 n.* += 1; 677 } 678 679 // recursively copy the contents of src_dir into dest_dir 680 fn copyDir(io: std.Io, src_dir: std.Io.Dir, dest_dir: std.Io.Dir) !void { 681 var iter = src_dir.iterate(); 682 while (try iter.next(io)) |entry| { 683 switch (entry.kind) { 684 .file => try src_dir.copyFile(entry.name, dest_dir, entry.name, io, .{}), 685 .directory => { 686 try dest_dir.createDirPath(io, entry.name); 687 var dest_entry_dir = try dest_dir.openDir(io, entry.name, .{ .access_sub_paths = true, .iterate = true, .follow_symlinks = false }); 688 defer dest_entry_dir.close(io); 689 var src_entry_dir = try src_dir.openDir(io, entry.name, .{ .access_sub_paths = true, .iterate = true, .follow_symlinks = false }); 690 defer src_entry_dir.close(io); 691 try copyDir(io, src_entry_dir, dest_entry_dir); 692 }, 693 else => {}, 694 } 695 } 696 } 697