MCPcopy Create free account
hub / github.com/angular/dev-infra / get

Method get

ng-dev/utils/git/authenticated-git-client.ts:166–188  ·  view source on GitHub ↗

* Static method to get the singleton instance of the `AuthenticatedGitClient`, * creating it if it has not yet been created.

()

Source from the content-addressed store, hash-verified

164 private static _authenticatedInstance: Promise<AuthenticatedGitClient> | null = null;
165 /** The previously configured user type. */
166 private static _userType: 'user' | 'bot';
167
168 /**
169 * Static method to get the singleton instance of the `AuthenticatedGitClient`,
170 * creating it if it has not yet been created.
171 */
172 static override async get(): Promise<AuthenticatedGitClient> {
173 if (AuthenticatedGitClient._token === null) {
174 throw new Error('No instance of `AuthenticatedGitClient` has been configured.');
175 }
176
177 // If there is no cached authenticated instance, create one and cache the promise
178 // immediately. This avoids constructing a client twice accidentally when e.g. waiting
179 // for the configuration to be loaded.
180 if (AuthenticatedGitClient._authenticatedInstance === null) {
181 AuthenticatedGitClient._authenticatedInstance = (async (
182 token: string,
183 userType: UserType,
184 tokenEnvironmentVariable: TokenEnvironmentVariable | null,
185 ) => {
186 return new AuthenticatedGitClient(
187 token,
188 userType,
189 await getConfig([assertValidGithubConfig]),
190 undefined,
191 tokenEnvironmentVariable,

Callers 1

Calls 1

getConfigFunction · 0.85

Tested by

no test coverage detected