@@ -511,7 +511,7 @@ namespace Private {
511
511
PathExt . join ( path , c . name ) , c , fileTypeForPath ) ;
512
512
} )
513
513
} as Contents . IModel ;
514
- } else if ( contents . type === 'file' ) {
514
+ } else if ( contents . type === 'file' || contents . type === 'symlink' ) {
515
515
// If it is a file or blob, convert to a file
516
516
const fileType = fileTypeForPath ( path ) ;
517
517
const fileContents = ( contents as GitHubFileContents ) . content ;
@@ -551,6 +551,16 @@ namespace Private {
551
551
mimetype : null ,
552
552
content : null
553
553
}
554
+ } else if ( contents . type === 'submodule' ) {
555
+ // If it is a submodule, throw an error, since we cannot
556
+ // GET submodules at the moment. NOTE: due to a bug in the GithHub
557
+ // API, the `type` for submodules in a directory listing is incorrectly
558
+ // reported as `file`: https://github.com/github/developer.github.com/commit/1b329b04cece9f3087faa7b1e0382317a9b93490
559
+ // This means submodules will show up in the listing, but we still should not
560
+ // open them.
561
+ throw makeError ( 400 , `Cannot open "${ contents . name } " because it is a submodule` ) ;
562
+ } else {
563
+ throw makeError ( 500 , `"${ contents . name } " has and unexpected type: ${ contents . type } ` ) ;
554
564
}
555
565
}
556
566
@@ -592,4 +602,22 @@ namespace Private {
592
602
content
593
603
} ;
594
604
}
605
+
606
+ /**
607
+ * Wrap an API error in a hacked-together error object
608
+ * masquerading as an `ServerConnection.IError`.
609
+ */
610
+ function makeError ( code : number , message : string ) : ServerConnection . IError {
611
+ const xhr = {
612
+ status : code ,
613
+ responseText : message
614
+ } ;
615
+ return {
616
+ event : undefined ,
617
+ xhr : xhr as XMLHttpRequest ,
618
+ ajaxSettings : null ,
619
+ throwError : xhr . responseText ,
620
+ message : xhr . responseText
621
+ } as any as ServerConnection . IError ;
622
+ }
595
623
}
0 commit comments