@@ -511,7 +511,7 @@ namespace Private {
511511 PathExt . join ( path , c . name ) , c , fileTypeForPath ) ;
512512 } )
513513 } as Contents . IModel ;
514- } else if ( contents . type === 'file' ) {
514+ } else if ( contents . type === 'file' || contents . type === 'symlink' ) {
515515 // If it is a file or blob, convert to a file
516516 const fileType = fileTypeForPath ( path ) ;
517517 const fileContents = ( contents as GitHubFileContents ) . content ;
@@ -551,6 +551,16 @@ namespace Private {
551551 mimetype : null ,
552552 content : null
553553 }
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 } ` ) ;
554564 }
555565 }
556566
@@ -592,4 +602,22 @@ namespace Private {
592602 content
593603 } ;
594604 }
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+ }
595623}
0 commit comments