feature: add pattern to .gitignore by unstaged changes' context menu

This commit is contained in:
leo 2024-06-16 19:42:12 +08:00
parent 20f5a6eb13
commit 89f9eb3d90
6 changed files with 97 additions and 12 deletions

16
src/Commands/GitIgnore.cs Normal file
View file

@ -0,0 +1,16 @@
using System.IO;
namespace SourceGit.Commands
{
public static class GitIgnore
{
public static void Add(string repo, string pattern)
{
var file = Path.Combine(repo, ".gitignore");
if (!File.Exists(file))
File.WriteAllLines(file, [ pattern ]);
else
File.AppendAllLines(file, [ pattern ]);
}
}
}