Remove the requiresAuthentication parameter
It is true by default and no place in the codebase sets it to false. We can simplify the code by removing this case we aren't using. If we want this behaviour in the future we can always implement it again, but I think it's likely to be unnecessary and if you don't want authenticated requests then you likely won't be initializing a Credentials object.
This commit is contained in:
@@ -90,24 +90,17 @@ export class Credentials {
|
||||
/**
|
||||
* Creates or returns an instance of Octokit.
|
||||
*
|
||||
* @param requireAuthentication Whether the Octokit instance needs to be authenticated as user.
|
||||
* @returns An instance of Octokit.
|
||||
*/
|
||||
async getOctokit(requireAuthentication = true): Promise<Octokit.Octokit> {
|
||||
async getOctokit(): Promise<Octokit.Octokit> {
|
||||
if (this.octokit) {
|
||||
return this.octokit;
|
||||
}
|
||||
|
||||
this.octokit = await this.createOctokit(requireAuthentication);
|
||||
this.octokit = await this.createOctokit(true);
|
||||
|
||||
if (!this.octokit) {
|
||||
if (requireAuthentication) {
|
||||
throw new Error("Did not initialize Octokit.");
|
||||
}
|
||||
|
||||
// We don't want to set this in this.octokit because that would prevent
|
||||
// authenticating when requireCredentials is true.
|
||||
return new Octokit.Octokit({ retry });
|
||||
throw new Error("Did not initialize Octokit.");
|
||||
}
|
||||
return this.octokit;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ export async function promptImportGithubDatabase(
|
||||
}
|
||||
|
||||
const octokit = credentials
|
||||
? await credentials.getOctokit(true)
|
||||
? await credentials.getOctokit()
|
||||
: new Octokit.Octokit({ retry });
|
||||
|
||||
const result = await convertGithubNwoToDatabaseUrl(nwo, octokit, progress);
|
||||
|
||||
Reference in New Issue
Block a user