@@ -214,16 +214,32 @@ async function setupLiveView() {
214214
215215 let fileContent ;
216216
217+ // get repo obj from local storage
218+ const repoObj = modifiedRepos [ user + '/' + repoName ] ;
219+
220+
217221 // if not logged in
222+ // or repository is public
218223 // and fetching an HTML file
219- if ( gitToken === ''
224+ if ( ( gitToken === ''
225+ || ( repoObj && ! repoObj . private ) )
220226 && getFileType ( fileName ) === 'html' ) {
221227
222228 // if branch doesn't exist in tree
223229 if ( ! treeLoc [ 1 ] . includes ( ':' ) ) {
224230
231+ let defaultBranch ;
232+
225233 // get default branch
226- const defaultBranch = ( await git . getRepo ( treeLoc ) ) . default_branch ;
234+ if ( repoObj && repoObj . defaultBranch ) {
235+
236+ defaultBranch = repoObj . defaultBranch ;
237+
238+ } else {
239+
240+ defaultBranch = ( await git . getRepo ( treeLoc ) ) . default_branch ;
241+
242+ }
227243
228244 // add branch to tree
229245 treeLoc [ 1 ] = treeLoc [ 1 ] . split ( ':' ) [ 0 ] + ':' + defaultBranch ;
@@ -798,14 +814,30 @@ async function handleLiveViewRequest(requestPath) {
798814
799815 let respObj ;
800816
817+ // get repo obj from local storage
818+ const repoObj = modifiedRepos [ user + '/' + repoName ] ;
819+
820+
801821 // if not logged in
802- if ( gitToken === '' ) {
822+ // or repository is public
823+ if ( gitToken === ''
824+ || ( repoObj && ! repoObj . private ) ) {
803825
804826 // if branch doesn't exist in tree
805827 if ( ! treeLoc [ 1 ] . includes ( ':' ) ) {
806828
829+ let defaultBranch ;
830+
807831 // get default branch
808- const defaultBranch = ( await git . getRepo ( treeLoc ) ) . default_branch ;
832+ if ( repoObj && repoObj . defaultBranch ) {
833+
834+ defaultBranch = repoObj . defaultBranch ;
835+
836+ } else {
837+
838+ defaultBranch = ( await git . getRepo ( treeLoc ) ) . default_branch ;
839+
840+ }
809841
810842 // add branch to tree
811843 treeLoc [ 1 ] = treeLoc [ 1 ] . split ( ':' ) [ 0 ] + ':' + defaultBranch ;
0 commit comments