Skip to content

Commit 8a75ef7

Browse files
committed
Close #423--mostly
1 parent a4c1c06 commit 8a75ef7

File tree

6 files changed

+49
-3
lines changed

6 files changed

+49
-3
lines changed

RetailCoder.VBE/UI/SourceControl/ChangesViewViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ private void Commit()
186186
{
187187
RaiseErrorEvent(ex.Message, ex.InnerException.Message, NotificationType.Error);
188188
}
189+
190+
CommitMessage = string.Empty;
189191
}
190192

191193
private void IncludeChanges(IFileStatusEntry fileStatusEntry)

RetailCoder.VBE/UI/SourceControl/SourceControlViewViewModel.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ public ISourceControlProvider Provider
174174
_provider = value;
175175
SetChildPresenterSourceControlProviders(_provider);
176176

177-
if (_fileSystemWatcher.Path != LocalDirectory)
177+
Provider.ExportFilesStarted += Provider_ExportFilesStarted;
178+
Provider.ExportFilesCompleted += Provider_ExportFilesCompleted;
179+
180+
if (_fileSystemWatcher.Path != LocalDirectory && Directory.Exists(_provider.CurrentRepository.LocalLocation))
178181
{
179182
_fileSystemWatcher.Path = _provider.CurrentRepository.LocalLocation;
180183
_fileSystemWatcher.EnableRaisingEvents = true;
@@ -188,6 +191,16 @@ public ISourceControlProvider Provider
188191
}
189192
}
190193

194+
private void Provider_ExportFilesCompleted(object sender, EventArgs e)
195+
{
196+
_fileSystemWatcher.EnableRaisingEvents = true;
197+
}
198+
199+
private void Provider_ExportFilesStarted(object sender, EventArgs e)
200+
{
201+
_fileSystemWatcher.EnableRaisingEvents = false;
202+
}
203+
191204
private void _fileSystemWatcher_Changed(object sender, FileSystemEventArgs e)
192205
{
193206
// the file system filter doesn't support multiple filters
@@ -780,7 +793,7 @@ private void Refresh()
780793
}
781794
}
782795

783-
if (Provider != null)
796+
if (Provider != null && Directory.Exists(Provider.CurrentRepository.LocalLocation))
784797
{
785798
_fileSystemWatcher.EnableRaisingEvents = true;
786799
}

Rubberduck.SourceControl/GitProvider.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,6 @@ public override IEnumerable<IFileStatusEntry> Status()
491491
}
492492
}
493493

494-
495494
public override IEnumerable<IFileStatusEntry> LastKnownStatus()
496495
{
497496
try

Rubberduck.SourceControl/ISourceControlProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public interface ISourceControlProvider
1313
IList<ICommit> UnsyncedRemoteCommits { get; }
1414

1515
event EventHandler<EventArgs> BranchChanged;
16+
event EventHandler<EventArgs> ExportFilesStarted;
17+
event EventHandler<EventArgs> ExportFilesCompleted;
1618

1719
/// <summary>Clone a remote repository.</summary>
1820
/// <param name="remotePathOrUrl">Either a Url "https://github.com/retailcoder/Rubberduck.git" or a UNC path. "//server/share/path/to/repo.git"</param>

Rubberduck.SourceControl/SourceControlProviderBase.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ public virtual IRepository InitVBAProject(string directory)
6464
Directory.CreateDirectory(directory);
6565
}
6666

67+
OnExportFilesStarted();
6768
Project.ExportSourceFiles(directory);
69+
OnExportFilesCompleted();
70+
6871
CurrentRepository = new Repository(Project.HelpFile, directory, directory);
6972
return CurrentRepository;
7073
}
@@ -78,12 +81,16 @@ public virtual void Pull()
7881

7982
public virtual void Stage(string filePath)
8083
{
84+
OnExportFilesStarted();
8185
Project.ExportSourceFiles(CurrentRepository.LocalLocation);
86+
OnExportFilesCompleted();
8287
}
8388

8489
public virtual void Stage(IEnumerable<string> filePaths)
8590
{
91+
OnExportFilesStarted();
8692
Project.ExportSourceFiles(CurrentRepository.LocalLocation);
93+
OnExportFilesCompleted();
8794
}
8895

8996
public virtual void Merge(string sourceBranch, string destinationBranch)
@@ -121,7 +128,9 @@ public virtual void Revert()
121128

122129
public virtual IEnumerable<IFileStatusEntry> Status()
123130
{
131+
OnExportFilesStarted();
124132
Project.ExportSourceFiles(CurrentRepository.LocalLocation);
133+
OnExportFilesCompleted();
125134
return null;
126135
}
127136

@@ -161,5 +170,25 @@ private void Refresh()
161170
Project.ImportSourceFiles(CurrentRepository.LocalLocation);
162171
}
163172
}
173+
174+
public event EventHandler<EventArgs> ExportFilesStarted;
175+
private void OnExportFilesStarted()
176+
{
177+
var handler = ExportFilesStarted;
178+
if (handler != null)
179+
{
180+
handler(this, EventArgs.Empty);
181+
}
182+
}
183+
184+
public event EventHandler<EventArgs> ExportFilesCompleted;
185+
private void OnExportFilesCompleted()
186+
{
187+
var handler = ExportFilesCompleted;
188+
if (handler != null)
189+
{
190+
handler(this, EventArgs.Empty);
191+
}
192+
}
164193
}
165194
}

RubberduckTests/SourceControl/SourceControlViewModelTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public void InitializeMocks()
7171
_provider.SetupGet(git => git.UnsyncedRemoteCommits).Returns(new List<ICommit>());
7272
_provider.Setup(git => git.InitVBAProject(It.IsAny<string>())).Returns(GetDummyRepo());
7373
_provider.Setup(git => git.Clone(It.IsAny<string>(), It.IsAny<string>())).Returns(GetDummyRepo());
74+
_provider.Setup(git => git.CurrentRepository).Returns(GetDummyRepo());
7475

7576
_providerFactory = new Mock<ISourceControlProviderFactory>();
7677
_providerFactory.Setup(f => f.CreateProvider(It.IsAny<VBProject>()))

0 commit comments

Comments
 (0)