From ffeb63613c969e310080dbd70830e6c83e4d1292 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 7 Nov 2024 17:18:04 +0800 Subject: [PATCH] fix: ignoring new files under folder creates invalid .gitignore entries (#663) Signed-off-by: leo --- src/ViewModels/WorkingCopy.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index 4bac8e08..00680251 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -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);