refactor(dev-infra): cleanup comments in git utilities (#38656)

Cleans up outdated comments in the shared dev-infra Git
utilities. We also export the Graphql client for consistency
as we expose the `GithubClient` and `GitClient` too.

PR Close #38656
This commit is contained in:
Paul Gschwendtner 2020-09-09 14:44:14 +02:00 committed by Alex Rickabaugh
parent 9dccaa9570
commit 69bb49e530
2 changed files with 12 additions and 15 deletions

View File

@ -69,18 +69,13 @@ export class GithubClient extends Octokit {
} }
/** /**
* An object representation of a GraphQL Query to be used as a response type and to generate * An object representation of a GraphQL Query to be used as a response type and
* a GraphQL query string. * to generate a GraphQL query string.
*/ */
type GraphQLQueryObject = Parameters<typeof query>[1]; export type GraphQLQueryObject = Parameters<typeof query>[1];
/** /** A client for interacting with Github's GraphQL API. */
* A client for interacting with Github's GraphQL API. export class GithubGraphqlClient {
*
* This class is intentionally not exported as it should always be access/used via a
* _GithubClient instance.
*/
class GithubGraphqlClient {
/** The Github GraphQL (v4) API. */ /** The Github GraphQL (v4) API. */
private graqhql = graphql; private graqhql = graphql;

View File

@ -33,16 +33,16 @@ export class GitCommandError extends Error {
} }
/** /**
* Common client for performing Git interactions. * Common client for performing Git interactions with a given remote.
* *
* Takes in two optional arguments: * Takes in two optional arguments:
* _githubToken: the token used for authentifation in github interactions, by default empty * `githubToken`: the token used for authentication in Github interactions, by default empty
* allowing readonly actions. * allowing readonly actions.
* _config: The dev-infra configuration containing GitClientConfig information, by default * `config`: The dev-infra configuration containing information about the remote. By default
* loads the config from the default location. * the dev-infra configuration is loaded with its Github configuration.
**/ **/
export class GitClient { export class GitClient {
/** Short-hand for accessing the remote configuration. */ /** Short-hand for accessing the default remote configuration. */
remoteConfig = this._config.github; remoteConfig = this._config.github;
/** Octokit request parameters object for targeting the configured remote. */ /** Octokit request parameters object for targeting the configured remote. */
remoteParams = {owner: this.remoteConfig.owner, repo: this.remoteConfig.name}; remoteParams = {owner: this.remoteConfig.owner, repo: this.remoteConfig.name};
@ -91,6 +91,8 @@ export class GitClient {
// commands unless the `stdio` is explicitly to `ignore` (which is equivalent to silent). // commands unless the `stdio` is explicitly to `ignore` (which is equivalent to silent).
// Note that we do not want to print the token if is contained in the command. It's common // Note that we do not want to print the token if is contained in the command. It's common
// to share errors with others if the tool failed, and we do not want to leak tokens. // to share errors with others if the tool failed, and we do not want to leak tokens.
// TODO: Add support for configuring this on a per-client basis. Some tools do not want
// to print the Git command messages to the console at all (e.g. to maintain clean output).
const printFn = options.stdio !== 'ignore' ? info : debug; const printFn = options.stdio !== 'ignore' ? info : debug;
printFn('Executing: git', this.omitGithubTokenFromMessage(args.join(' '))); printFn('Executing: git', this.omitGithubTokenFromMessage(args.join(' ')));