Skip to content

Commit 7714d80

Browse files
committed
Remove file from working directory when removed from VBE
1 parent 8b39944 commit 7714d80

File tree

6 files changed

+23
-7
lines changed

6 files changed

+23
-7
lines changed

RetailCoder.VBE/App.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ async void sink_ComponentRemoved(object sender, DispatcherEventArgs<VBComponent>
325325
return;
326326
}
327327

328+
_panelVM.RemoveComponent(e.Item);
329+
328330
_logger.Debug("Component '{0}' was removed.", e.Item.Name);
329331
_parser.State.ClearStateCache(e.Item, true);
330332
}

RetailCoder.VBE/UI/SourceControl/SourceControlViewViewModel.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ public void AddComponent(VBComponent component)
101101
}
102102
}
103103

104+
public void RemoveComponent(VBComponent component)
105+
{
106+
if (Provider == null) { return; }
107+
108+
var fileStatus = Provider.Status().SingleOrDefault(stat => stat.FilePath.Split('.')[0] == component.Name);
109+
if (fileStatus != null)
110+
{
111+
Provider.RemoveFile(fileStatus.FilePath, true);
112+
}
113+
}
114+
104115
private static readonly IDictionary<NotificationType, BitmapImage> IconMappings =
105116
new Dictionary<NotificationType, BitmapImage>
106117
{

Rubberduck.SourceControl/GitProvider.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public GitProvider(VBProject project, IRepository repository, ICodePaneWrapperFa
3737
}
3838
catch (RepositoryNotFoundException ex)
3939
{
40+
repository = null;
4041
throw new SourceControlException(SourceControlText.GitRepoNotFound, ex);
4142
}
4243
}
@@ -437,14 +438,15 @@ public override void AddFile(string filePath)
437438
}
438439

439440
/// <summary>
440-
/// Removes file from staging area, but leaves the file in the working directory.
441+
/// Removes file from staging area.
441442
/// </summary>
442443
/// <param name="filePath"></param>
443-
public override void RemoveFile(string filePath)
444+
/// <param name="removeFromWorkingDirectory"></param>
445+
public override void RemoveFile(string filePath, bool removeFromWorkingDirectory)
444446
{
445447
try
446448
{
447-
_repo.Remove(filePath, false);
449+
_repo.Remove(filePath, removeFromWorkingDirectory);
448450
}
449451
catch (LibGit2SharpException ex)
450452
{
@@ -457,7 +459,8 @@ public override IEnumerable<IFileStatusEntry> Status()
457459
try
458460
{
459461
base.Status();
460-
return _repo.RetrieveStatus().Select(item => new FileStatusEntry(item));
462+
return _repo.RetrieveStatus(new StatusOptions {IncludeUnaltered = true})
463+
.Select(item => new FileStatusEntry(item));
461464
}
462465
catch (LibGit2SharpException ex)
463466
{

Rubberduck.SourceControl/ISourceControlProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public interface ISourceControlProvider
112112
/// Removes file from tracking.
113113
/// </summary>
114114
/// <param name="filePath"></param>
115-
void RemoveFile(string filePath);
115+
void RemoveFile(string filePath, bool removeFromWorkingDirectory);
116116

117117
/// <summary>
118118
/// Returns a collection of file status entries.

Rubberduck.SourceControl/Interop/ISourceControlProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public interface ISourceControlProvider
7575

7676
[DispId(16)]
7777
[Description("Removes file from tracking.")]
78-
void RemoveFile(string filePath);
78+
void RemoveFile(string filePath, bool removeFromWorkingDirectory);
7979

8080
[DispId(17)]
8181
[Description("Returns a collection of file status entries.\n Semantically the same as calling $git status.")]

Rubberduck.SourceControl/SourceControlProviderBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected SourceControlProviderBase(VBProject project, IRepository repository, I
3535
public abstract void Push();
3636
public abstract void Fetch(string remoteName);
3737
public abstract void AddFile(string filePath);
38-
public abstract void RemoveFile(string filePath);
38+
public abstract void RemoveFile(string filePath, bool removeFromWorkingDirectory);
3939
public abstract void CreateBranch(string branch);
4040
public abstract void DeleteBranch(string branch);
4141
public abstract IRepository Init(string directory, bool bare = false);

0 commit comments

Comments
 (0)