This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +15
-10
lines changed
GitHub.App/ViewModels/GitHubPane
GitHub.VisualStudio.UI/Base
test/UnitTests/GitHub.Api Expand file tree Collapse file tree 6 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ async Task<Repository> GetRepositoryInternal()
7272 if ( repo != null )
7373 {
7474 hasWiki = await HasWikiInternal ( repo ) ;
75- isEnterprise = await IsEnterpriseInternal ( ) ;
75+ isEnterprise = isEnterprise ?? await IsEnterpriseInternal ( ) ;
7676 repositoryCache = repo ;
7777 }
7878 owner = ownerLogin ;
@@ -99,9 +99,14 @@ public bool HasWiki()
9999 return hasWiki . HasValue && hasWiki . Value ;
100100 }
101101
102- public bool IsEnterprise ( )
102+ public async Task < bool > IsEnterprise ( )
103103 {
104- return isEnterprise . HasValue && isEnterprise . Value ;
104+ if ( ! isEnterprise . HasValue )
105+ {
106+ isEnterprise = await IsEnterpriseInternal ( ) ;
107+ }
108+
109+ return isEnterprise ?? false ;
105110 }
106111
107112 async Task < bool > HasWikiInternal ( Repository repo )
Original file line number Diff line number Diff line change @@ -366,7 +366,7 @@ async Task UpdateContent(ILocalRepositoryModel repository)
366366 var repositoryUrl = repository . CloneUrl . ToRepositoryUrl ( ) ;
367367 var isDotCom = HostAddress . IsGitHubDotComUri ( repositoryUrl ) ;
368368 var client = await apiClientFactory . Create ( repository . CloneUrl ) ;
369- var isEnterprise = isDotCom ? false : client . IsEnterprise ( ) ;
369+ var isEnterprise = isDotCom ? false : await client . IsEnterprise ( ) ;
370370
371371 if ( ( isDotCom || isEnterprise ) && await IsValidRepository ( client ) )
372372 {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public interface ISimpleApiClient
1111 UriString OriginalUrl { get ; }
1212 Task < Repository > GetRepository ( ) ;
1313 bool HasWiki ( ) ;
14- bool IsEnterprise ( ) ;
14+ Task < bool > IsEnterprise ( ) ;
1515 bool IsAuthenticated ( ) ;
1616 }
1717}
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ protected async Task<RepositoryOrigin> GetRepositoryOrigin()
126126 {
127127 var repo = await SimpleApiClient . GetRepository ( ) ;
128128
129- if ( ( repo . FullName == ActiveRepoName || repo . Id == 0 ) && SimpleApiClient . IsEnterprise ( ) )
129+ if ( ( repo . FullName == ActiveRepoName || repo . Id == 0 ) && await SimpleApiClient . IsEnterprise ( ) )
130130 {
131131 return RepositoryOrigin . Enterprise ;
132132 }
Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ protected async Task<bool> IsGitHubRepo()
123123 {
124124 var repo = await SimpleApiClient . GetRepository ( ) ;
125125 var activeRepoFullName = ActiveRepo . Owner + '/' + ActiveRepo . Name ;
126- return ( repo . FullName == activeRepoFullName || repo . Id == 0 ) && SimpleApiClient . IsEnterprise ( ) ;
126+ return ( repo . FullName == activeRepoFullName || repo . Id == 0 ) && await SimpleApiClient . IsEnterprise ( ) ;
127127 }
128128 return isdotcom ;
129129 }
Original file line number Diff line number Diff line change @@ -132,10 +132,10 @@ public async Task ReturnsTrueWhenEnterpriseProbeReturnsOk(EnterpriseProbeResult
132132 new Lazy < IWikiProbe > ( ( ) => wikiProbe ) ) ;
133133 await client . GetRepository ( ) ;
134134
135- var result = client . IsEnterprise ( ) ;
135+ var result = await client . IsEnterprise ( ) ;
136136
137137 Assert . That ( expected , Is . EqualTo ( result ) ) ;
138- Assert . That ( expected , Is . EqualTo ( client . IsEnterprise ( ) ) ) ;
138+ Assert . That ( expected , Is . EqualTo ( await client . IsEnterprise ( ) ) ) ;
139139 }
140140
141141 [ Test ]
@@ -151,7 +151,7 @@ public void ReturnsFalseWhenWeHaveNotRequestedRepository()
151151 new Lazy < IEnterpriseProbe > ( ( ) => enterpriseProbe ) ,
152152 new Lazy < IWikiProbe > ( ( ) => wikiProbe ) ) ;
153153
154- var result = client . IsEnterprise ( ) ;
154+ var result = client . IsEnterprise ( ) . Result ;
155155
156156 Assert . False ( result ) ;
157157 }
You can’t perform that action at this time.
0 commit comments