Skip to content

Commit 09e65aa

Browse files
committed
Close #157
1 parent 151566f commit 09e65aa

File tree

3 files changed

+40
-11
lines changed

3 files changed

+40
-11
lines changed

RetailCoder.VBE/UI/SourceControl/SourceControlViewViewModel.cs

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public enum SourceControlTab
2525
UnsyncedCommits,
2626
Settings
2727
}
28-
28+
2929
public sealed class SourceControlViewViewModel : ViewModelBase, IDisposable
3030
{
3131
private readonly VBE _vbe;
@@ -368,11 +368,11 @@ private void AddOrUpdateLocalPathConfig(Repository repo)
368368
var existing = _config.Repositories.Single(repository => repository.LocalLocation == repo.LocalLocation);
369369
if (string.IsNullOrEmpty(repo.RemoteLocation) && !string.IsNullOrEmpty(existing.RemoteLocation))
370370
{
371-
// config already has remote location and correct repository name - nothing to update
371+
// config already has remote location and correct repository id - nothing to update
372372
return;
373373
}
374374

375-
existing.Name = repo.Name;
375+
existing.Id = repo.Id;
376376
existing.RemoteLocation = repo.RemoteLocation;
377377

378378
_configService.Save(_config);
@@ -391,15 +391,18 @@ private void OpenRepo()
391391
var project = _vbe.ActiveVBProject;
392392
var repo = new Repository(project.Name, folderPicker.SelectedPath, string.Empty);
393393

394+
OnOpenRepoStarted();
394395
try
395396
{
396397
Provider = _providerFactory.CreateProvider(project, repo, _wrapperFactory);
397398
}
398399
catch (SourceControlException ex)
399400
{
401+
OnOpenRepoCompleted();
400402
ViewModel_ErrorThrown(null, new ErrorEventArgs(ex.Message, ex.InnerException.Message, NotificationType.Error));
401403
return;
402404
}
405+
OnOpenRepoCompleted();
403406

404407
AddOrUpdateLocalPathConfig(repo);
405408

@@ -409,14 +412,16 @@ private void OpenRepo()
409412

410413
private void CloneRepo()
411414
{
415+
OnOpenRepoStarted();
416+
412417
try
413418
{
414419
_provider = _providerFactory.CreateProvider(_vbe.ActiveVBProject);
415420
var repo = _provider.Clone(RemotePath, LocalDirectory);
416421
Provider = _providerFactory.CreateProvider(_vbe.ActiveVBProject, repo, _wrapperFactory);
417422
AddOrUpdateLocalPathConfig(new Repository
418423
{
419-
Name = _vbe.ActiveVBProject.Name,
424+
Id = _vbe.ActiveVBProject.HelpFile,
420425
LocalLocation = repo.LocalLocation,
421426
RemoteLocation = repo.RemoteLocation
422427
});
@@ -427,6 +432,7 @@ private void CloneRepo()
427432
return;
428433
}
429434

435+
OnOpenRepoCompleted();
430436
CloseCloneRepoGrid();
431437

432438
SetChildPresenterSourceControlProviders(_provider);
@@ -454,15 +460,18 @@ private void OpenRepoAssignedToProject()
454460

455461
try
456462
{
463+
OnOpenRepoStarted();
457464
Provider = _providerFactory.CreateProvider(_vbe.ActiveVBProject,
458-
_config.Repositories.First(repo => repo.Name == _vbe.ActiveVBProject.Name), _wrapperFactory);
465+
_config.Repositories.First(repo => repo.Id == _vbe.ActiveVBProject.HelpFile), _wrapperFactory);
459466
Status = RubberduckUI.Online;
460467
}
461468
catch (SourceControlException ex)
462469
{
463470
ViewModel_ErrorThrown(null, new ErrorEventArgs(ex.Message, ex.InnerException.Message, NotificationType.Error));
464471
Status = RubberduckUI.Offline;
465472
}
473+
474+
OnOpenRepoCompleted();
466475
}
467476

468477
private void Refresh()
@@ -487,7 +496,7 @@ private bool ValidRepoExists()
487496
return false;
488497
}
489498

490-
var possibleRepos = _config.Repositories.Where(repo => repo.Name == _vbe.ActiveVBProject.Name);
499+
var possibleRepos = _config.Repositories.Where(repo => repo.Id == _vbe.ActiveVBProject.HelpFile);
491500

492501
var possibleCount = possibleRepos.Count();
493502

@@ -535,7 +544,7 @@ public ICommand CloneRepoCommand
535544
{
536545
get { return _cloneRepoCommand; }
537546
}
538-
547+
539548
private readonly ICommand _showFilePickerCommand;
540549
public ICommand ShowFilePickerCommand
541550
{
@@ -590,6 +599,26 @@ public ICommand LoginGridCancelCommand
590599
}
591600
}
592601

602+
public event EventHandler<EventArgs> OpenRepoStarted;
603+
private void OnOpenRepoStarted()
604+
{
605+
var handler = OpenRepoStarted;
606+
if (handler != null)
607+
{
608+
handler(this, EventArgs.Empty);
609+
}
610+
}
611+
612+
public event EventHandler<EventArgs> OpenRepoCompleted;
613+
private void OnOpenRepoCompleted()
614+
{
615+
var handler = OpenRepoCompleted;
616+
if (handler != null)
617+
{
618+
handler(this, EventArgs.Empty);
619+
}
620+
}
621+
593622
public void Dispose()
594623
{
595624
if (_state != null)

Rubberduck.SourceControl/IRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Rubberduck.SourceControl
88
public interface IRepository
99
{
1010
[DispId(0)]
11-
string Name { get; }
11+
string Id { get; }
1212

1313
[DispId(1)]
1414
[Description("FilePath of local repository.")]

Rubberduck.SourceControl/Repository.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ namespace Rubberduck.SourceControl
88
[ClassInterface(ClassInterfaceType.None)]
99
public class Repository : IRepository
1010
{
11-
public string Name { get; set; }
11+
public string Id { get; set; }
1212
public string LocalLocation { get; set; }
1313
public string RemoteLocation { get; set; }
1414

1515
//parameterless constructor for serialization
1616
public Repository() { }
1717

18-
public Repository(string name, string localDirectory, string remotePathOrUrl)
18+
public Repository(string id, string localDirectory, string remotePathOrUrl)
1919
{
20-
Name = name;
20+
Id = id;
2121
LocalLocation = localDirectory;
2222
RemoteLocation = remotePathOrUrl;
2323
}

0 commit comments

Comments
 (0)