fix: make sure the new pattern is appended as a new line (#1264)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-04-30 20:41:00 +08:00
parent 7501588c95
commit 9bde797b24
No known key found for this signature in database

View file

@ -8,7 +8,14 @@ namespace SourceGit.Commands
{
var file = Path.Combine(repo, ".gitignore");
if (!File.Exists(file))
{
File.WriteAllLines(file, [pattern]);
return;
}
var org = File.ReadAllText(file);
if (!org.EndsWith('\n'))
File.AppendAllLines(file, ["", pattern]);
else
File.AppendAllLines(file, [pattern]);
}