| ... | ... | @@ -120,6 +120,28 @@ pub fn execute(args: [][]u8) !void { |
| 120 | 120 | try w.writeAll("deps.zig\n"); |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | |
| 124 | // ask about .gitattributes |
| 125 | if (try u.does_folder_exist(".git")) { |
| 126 | const do = try inquirer.forConfirm(stdout, stdin, "It appears you're using git. Do you want init to add Zigmod to your .gitattributes?", gpa); |
| 127 | if (do) { |
| 128 | const exists = try u.does_file_exist(null, ".gitattributes"); |
| 129 | const file: std.fs.File = try (if (exists) cwd.openFile(".gitattributes", .{ .read = true, .write = true }) else cwd.createFile(".gitattributes", .{})); |
| 130 | defer file.close(); |
| 131 | const len = try file.getEndPos(); |
| 132 | if (len > 0) try file.seekTo(len - 1); |
| 133 | const w = file.writer(); |
| 134 | if (len > 0 and (try file.reader().readByte()) != '\n') { |
| 135 | try w.writeAll("\n"); |
| 136 | } |
| 137 | if (!exists) try w.writeAll("* text=auto\n"); |
| 138 | if (!exists) try w.writeAll("*.zig text eol=lf # See https://github.com/ziglang/zig-spec/issues/38\n"); |
| 139 | try w.writeAll("zig.mod text eol=lf\n"); |
| 140 | try w.writeAll("zigmod.* text eol=lf\n"); |
| 141 | try w.writeAll("zig.mod linguist-language=YAML\n"); |
| 142 | try w.writeAll("zig.mod gitlab-language=yaml\n"); |
| 143 | } |
| 144 | } |
| 123 | 145 | } |
| 124 | 146 | |
| 125 | 147 | pub fn writeExeManifest(w: std.fs.File.Writer, id: string, name: string, license: ?string, description: ?string) !void { |