Skip to content

Commit 9bde797

Browse files
committed
fix: make sure the new pattern is appended as a new line (#1264)
Signed-off-by: leo <[email protected]>
1 parent 7501588 commit 9bde797

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Commands/GitIgnore.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ public static void Add(string repo, string pattern)
88
{
99
var file = Path.Combine(repo, ".gitignore");
1010
if (!File.Exists(file))
11+
{
1112
File.WriteAllLines(file, [pattern]);
13+
return;
14+
}
15+
16+
var org = File.ReadAllText(file);
17+
if (!org.EndsWith('\n'))
18+
File.AppendAllLines(file, ["", pattern]);
1219
else
1320
File.AppendAllLines(file, [pattern]);
1421
}

0 commit comments

Comments
 (0)