@@ -199,6 +199,24 @@ public ITrackingCollection<IRepositoryModel> GetRepositories(ITrackingCollection
199199 return collection ;
200200 }
201201
202+ public IObservable < IPullRequestModel > CreatePullRequest ( ISimpleRepositoryModel repository , string title , IBranch source , IBranch target )
203+ {
204+ var keyobs = GetUserFromCache ( )
205+ . Select ( user => string . Format ( CultureInfo . InvariantCulture , "{0}|{1}:{2}" , CacheIndex . PRPrefix , user . Login , repository . Name ) ) ;
206+
207+ return Observable . Defer ( ( ) => keyobs
208+ . SelectMany ( key =>
209+ hostCache . PutAndUpdateIndex ( key , ( ) =>
210+ apiClient . CreatePullRequest ( new NewPullRequest ( title , source . Name , target . Name ) ,
211+ repository . CloneUrl . Owner ,
212+ repository . CloneUrl . RepositoryName )
213+ . Select ( PullRequestCacheItem . Create ) ,
214+ TimeSpan . FromMinutes ( 30 ) )
215+ )
216+ . Select ( Create )
217+ ) ;
218+ }
219+
202220 public IObservable < Unit > InvalidateAll ( )
203221 {
204222 return hostCache . InvalidateAll ( ) . ContinueAfter ( ( ) => hostCache . Vacuum ( ) ) ;
@@ -262,6 +280,16 @@ IObservable<IReadOnlyList<IRepositoryModel>> GetOrganizationRepositories(string
262280 } ) ;
263281 }
264282
283+ public IObservable < IBranch > GetBranches ( ISimpleRepositoryModel repo )
284+ {
285+ var keyobs = GetUserFromCache ( )
286+ . Select ( user => string . Format ( CultureInfo . InvariantCulture , "{0}|{1}|branch" , user . Login , repo . Name ) ) ;
287+
288+ return Observable . Defer ( ( ) => keyobs
289+ . SelectMany ( key => apiClient . GetBranches ( repo . CloneUrl . Owner , repo . CloneUrl . RepositoryName ) ) )
290+ . Select ( Create ) ;
291+ }
292+
265293 static GitIgnoreItem Create ( GitIgnoreCacheItem item )
266294 {
267295 return GitIgnoreItem . Create ( item . Name ) ;
@@ -272,7 +300,7 @@ static LicenseItem Create(LicenseCacheItem licenseCacheItem)
272300 return new LicenseItem ( licenseCacheItem . Key , licenseCacheItem . Name ) ;
273301 }
274302
275- Models . Account Create ( AccountCacheItem accountCacheItem )
303+ IAccount Create ( AccountCacheItem accountCacheItem )
276304 {
277305 return new Models . Account (
278306 accountCacheItem . Login ,
@@ -313,6 +341,11 @@ IPullRequestModel Create(PullRequestCacheItem prCacheItem)
313341 } ;
314342 }
315343
344+ IBranch Create ( Branch branch )
345+ {
346+ return new BranchModel ( branch ) ;
347+ }
348+
316349
317350 public IObservable < Unit > InsertUser ( AccountCacheItem user )
318351 {
0 commit comments