fix: ignoring new files under folder creates invalid .gitignore entries (#663)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-11-07 17:18:04 +08:00
parent 243ce8b06d
commit ffeb63613c
No known key found for this signature in database

View file

@ -599,7 +599,8 @@ namespace SourceGit.ViewModels
byParentFolder.IsVisible = !isRooted;
byParentFolder.Click += (_, e) =>
{
Commands.GitIgnore.Add(_repo.FullPath, Path.GetDirectoryName(change.Path) + "/");
var path = Path.GetDirectoryName(change.Path).Replace("\\", "/");
Commands.GitIgnore.Add(_repo.FullPath, path + "/");
e.Handled = true;
};
addToIgnore.Items.Add(byParentFolder);
@ -620,7 +621,8 @@ namespace SourceGit.ViewModels
byExtensionInSameFolder.IsVisible = !isRooted;
byExtensionInSameFolder.Click += (_, e) =>
{
Commands.GitIgnore.Add(_repo.FullPath, Path.GetDirectoryName(change.Path) + "/*" + extension);
var path = Path.GetDirectoryName(change.Path).Replace("\\", "/");
Commands.GitIgnore.Add(_repo.FullPath, path + "/*" + extension);
e.Handled = true;
};
addToIgnore.Items.Add(byExtensionInSameFolder);