11using System ;
22using System . Collections . Generic ;
3- using System . Diagnostics ;
43using System . Linq ;
54using System . Threading ;
65using System . Threading . Tasks ;
@@ -11,21 +10,13 @@ interface IRepositoryManager : IDisposable
1110 {
1211 event Action OnActiveBranchChanged ;
1312 event Action OnActiveRemoteChanged ;
14- event Action OnRemoteBranchListChanged ;
13+ event Action < bool > OnIsBusyChanged ;
1514 event Action OnLocalBranchListChanged ;
16- event Action < GitStatus > OnStatusUpdated ;
1715 event Action OnHeadChanged ;
18- event Action < bool > OnIsBusyChanged ;
19- event Action OnRemoteOrTrackingChanged ;
16+ event Action < GitStatus > OnStatusUpdated ;
2017 event Action < IEnumerable < GitLock > > OnLocksUpdated ;
21- Dictionary < string , ConfigBranch > LocalBranches { get ; }
22- Dictionary < string , Dictionary < string , ConfigBranch > > RemoteBranches { get ; }
23- IRepository Repository { get ; }
24- IGitConfig Config { get ; }
25- ConfigBranch ? ActiveBranch { get ; }
26- ConfigRemote ? ActiveRemote { get ; }
27- IGitClient GitClient { get ; }
28- bool IsBusy { get ; }
18+ event Action OnRemoteBranchListChanged ;
19+ event Action OnRemoteOrTrackingChanged ;
2920 Task Initialize ( ) ;
3021 void Start ( ) ;
3122 void Stop ( ) ;
@@ -44,6 +35,14 @@ interface IRepositoryManager : IDisposable
4435 ITask ListLocks ( bool local ) ;
4536 ITask LockFile ( string file ) ;
4637 ITask UnlockFile ( string file , bool force ) ;
38+ Dictionary < string , ConfigBranch > LocalBranches { get ; }
39+ Dictionary < string , Dictionary < string , ConfigBranch > > RemoteBranches { get ; }
40+ IRepository Repository { get ; }
41+ IGitConfig Config { get ; }
42+ ConfigBranch ? ActiveBranch { get ; }
43+ ConfigRemote ? ActiveRemote { get ; }
44+ IGitClient GitClient { get ; }
45+ bool IsBusy { get ; }
4746 }
4847
4948 interface IRepositoryPathConfiguration
@@ -91,17 +90,17 @@ public RepositoryPathConfiguration(NPath repositoryPath)
9190
9291 class RepositoryManagerFactory
9392 {
94- public RepositoryManager CreateRepositoryManager ( IPlatform platform , ITaskManager taskManager , IUsageTracker usageTracker ,
95- IGitClient gitClient , NPath repositoryRoot )
93+ public RepositoryManager CreateRepositoryManager ( IPlatform platform , ITaskManager taskManager ,
94+ IUsageTracker usageTracker , IGitClient gitClient , NPath repositoryRoot )
9695 {
9796 var repositoryPathConfiguration = new RepositoryPathConfiguration ( repositoryRoot ) ;
9897 string filePath = repositoryPathConfiguration . DotGitConfig ;
9998 var gitConfig = new GitConfig ( filePath ) ;
10099
101100 var repositoryWatcher = new RepositoryWatcher ( platform , repositoryPathConfiguration , taskManager . Token ) ;
102101
103- return new RepositoryManager ( platform , taskManager , usageTracker , gitConfig , repositoryWatcher ,
104- gitClient , repositoryPathConfiguration , taskManager . Token ) ;
102+ return new RepositoryManager ( platform , taskManager , usageTracker , gitConfig , repositoryWatcher , gitClient ,
103+ repositoryPathConfiguration , taskManager . Token ) ;
105104 }
106105 }
107106
@@ -110,34 +109,34 @@ class RepositoryManager : IRepositoryManager
110109 private readonly Dictionary < string , ConfigBranch > branches = new Dictionary < string , ConfigBranch > ( ) ;
111110 private readonly CancellationToken cancellationToken ;
112111 private readonly IGitConfig config ;
112+ private readonly IGitClient gitClient ;
113113 private readonly IPlatform platform ;
114+ private readonly IRepositoryPathConfiguration repositoryPaths ;
114115 private readonly ITaskManager taskManager ;
115116 private readonly IUsageTracker usageTracker ;
116- private IRepository repository ;
117- private readonly IRepositoryPathConfiguration repositoryPaths ;
118- private readonly IGitClient gitClient ;
119117 private readonly IRepositoryWatcher watcher ;
120118
121119 private ConfigBranch ? activeBranch ;
122120 private ConfigRemote ? activeRemote ;
123121 private string head ;
124122 private bool isBusy ;
123+ private IEnumerable < GitLock > locks ;
125124 private Dictionary < string , Dictionary < string , ConfigBranch > > remoteBranches = new Dictionary < string , Dictionary < string , ConfigBranch > > ( ) ;
126125 private Dictionary < string , ConfigRemote > remotes ;
127- private IEnumerable < GitLock > locks ;
126+ private IRepository repository ;
128127
129128 public event Action OnActiveBranchChanged ;
130129 public event Action OnActiveRemoteChanged ;
131- public event Action OnRemoteBranchListChanged ;
132- public event Action OnLocalBranchListChanged ;
133- public event Action < GitStatus > OnStatusUpdated ;
134130 public event Action OnHeadChanged ;
135131 public event Action < bool > OnIsBusyChanged ;
136- public event Action OnRemoteOrTrackingChanged ;
132+ public event Action OnLocalBranchListChanged ;
137133 public event Action < IEnumerable < GitLock > > OnLocksUpdated ;
134+ public event Action OnRemoteBranchListChanged ;
135+ public event Action OnRemoteOrTrackingChanged ;
136+ public event Action < GitStatus > OnStatusUpdated ;
138137
139- public RepositoryManager ( IPlatform platform , ITaskManager taskManager , IUsageTracker usageTracker , IGitConfig gitConfig ,
140- IRepositoryWatcher repositoryWatcher , IGitClient gitClient ,
138+ public RepositoryManager ( IPlatform platform , ITaskManager taskManager , IUsageTracker usageTracker ,
139+ IGitConfig gitConfig , IRepositoryWatcher repositoryWatcher , IGitClient gitClient ,
141140 IRepositoryPathConfiguration repositoryPaths , CancellationToken cancellationToken )
142141 {
143142 this . repositoryPaths = repositoryPaths ;
@@ -163,9 +162,11 @@ public RepositoryManager(IPlatform platform, ITaskManager taskManager, IUsageTra
163162
164163 var remote = config . GetRemote ( "origin" ) ;
165164 if ( ! remote . HasValue )
165+ {
166166 remote = config . GetRemotes ( )
167- . Where ( x => HostAddress . Create ( new UriString ( x . Url ) . ToRepositoryUri ( ) ) . IsGitHubDotCom ( ) )
168- . FirstOrDefault ( ) ;
167+ . Where ( x => HostAddress . Create ( new UriString ( x . Url ) . ToRepositoryUri ( ) ) . IsGitHubDotCom ( ) )
168+ . FirstOrDefault ( ) ;
169+ }
169170 UriString cloneUrl = "" ;
170171 if ( remote . Value . Url != null )
171172 {
@@ -398,8 +399,7 @@ private void Watcher_OnHeadChanged(string contents)
398399 }
399400
400401 private void Watcher_OnIndexChanged ( )
401- {
402- }
402+ { }
403403
404404 private void Watcher_OnLocalBranchCreated ( string name )
405405 {
@@ -436,6 +436,7 @@ private async Task<IRepository> InitializeRepository()
436436 {
437437 throw new InvalidOperationException ( "No user configured" ) ;
438438 }
439+
439440 user . Email = res ;
440441 repository . User = user ;
441442 return repository ;
@@ -599,6 +600,7 @@ private void RemoveRemoteBranch(string remote, string name)
599600 }
600601
601602 private bool disposed ;
603+
602604 private void Dispose ( bool disposing )
603605 {
604606 if ( disposed ) return ;
@@ -628,7 +630,8 @@ public ConfigBranch? ActiveBranch
628630 get { return activeBranch ; }
629631 private set
630632 {
631- if ( activeBranch . HasValue != value . HasValue || ( activeBranch . HasValue && ! activeBranch . Value . Equals ( value . Value ) ) )
633+ if ( activeBranch . HasValue != value . HasValue ||
634+ activeBranch . HasValue && ! activeBranch . Value . Equals ( value . Value ) )
632635 {
633636 activeBranch = value ;
634637 Logger . Trace ( "OnActiveBranchChanged: {0}" , value ? . ToString ( ) ?? "NULL" ) ;
@@ -642,7 +645,8 @@ public ConfigRemote? ActiveRemote
642645 get { return activeRemote ; }
643646 private set
644647 {
645- if ( activeRemote . HasValue != value . HasValue || ( activeRemote . HasValue && ! activeRemote . Value . Equals ( value . Value ) ) )
648+ if ( activeRemote . HasValue != value . HasValue ||
649+ activeRemote . HasValue && ! activeRemote . Value . Equals ( value . Value ) )
646650 {
647651 activeRemote = value ;
648652 Logger . Trace ( "OnActiveRemoteChanged: {0}" , value ? . ToString ( ) ?? "NULL" ) ;
0 commit comments