@@ -364,11 +364,19 @@ public virtual async Task<PullRequestDetailModel> ReadPullRequestDetail(HostAddr
364364 var files = await apiClient . GetPullRequestFiles ( owner , name , number ) . ToList ( ) ;
365365 var lastCommitModel = await GetPullRequestLastCommitAdapter ( address , owner , name , number ) ;
366366
367- result . Statuses = lastCommitModel . Statuses ;
368- result . CheckSuites = lastCommitModel . CheckSuites ;
369- foreach ( var checkSuite in result . CheckSuites )
367+ result . Statuses = ( IReadOnlyList < StatusModel > ) lastCommitModel . Statuses ?? Array . Empty < StatusModel > ( ) ;
368+
369+ if ( lastCommitModel . CheckSuites == null )
370370 {
371- checkSuite . HeadSha = lastCommitModel . HeadSha ;
371+ result . CheckSuites = Array . Empty < CheckSuiteModel > ( ) ;
372+ }
373+ else
374+ {
375+ result . CheckSuites = lastCommitModel . CheckSuites ;
376+ foreach ( var checkSuite in result . CheckSuites )
377+ {
378+ checkSuite . HeadSha = lastCommitModel . HeadSha ;
379+ }
372380 }
373381
374382 result . ChangedFiles = files . Select ( file => new PullRequestFileModel
@@ -829,16 +837,18 @@ async Task<LastCommitAdapter> GetPullRequestLastCommitAdapter(HostAddress addres
829837 . PullRequest ( Var ( nameof ( number ) ) ) . Commits ( last : 1 ) . Nodes . Select (
830838 commit => new LastCommitAdapter
831839 {
832- Statuses = commit . Commit . Status
833- . Select ( context =>
834- context . Contexts . Select ( statusContext => new StatusModel
835- {
836- State = statusContext . State . FromGraphQl ( ) ,
837- Context = statusContext . Context ,
838- TargetUrl = statusContext . TargetUrl ,
839- Description = statusContext . Description ,
840- } ) . ToList ( )
841- ) . SingleOrDefault ( )
840+ Statuses = commit . Commit . Status == null ? null : commit . Commit . Status
841+ . Select ( context => context == null
842+ ? null
843+ : context . Contexts
844+ . Select ( statusContext => new StatusModel
845+ {
846+ State = statusContext . State . FromGraphQl ( ) ,
847+ Context = statusContext . Context ,
848+ TargetUrl = statusContext . TargetUrl ,
849+ Description = statusContext . Description ,
850+ } ) . ToList ( )
851+ ) . SingleOrDefault ( )
842852 }
843853 ) . Compile ( ) ;
844854 }
0 commit comments