Skip to content

🩹 [Patch]: Support GH and Git CLI Configuration in Connect/Disconnect-GitHub with skip options #391

Open
@MariusStorhaug

Description

@MariusStorhaug

Describe the change

Summary

Add support to automatically configure the GitHub CLI (gh) and Git for the relevant account/context when running Connect-GitHubAccount, Disconnect-GitHubAccount, and Connect-GitHubApp.
This should streamline authentication and configuration for users, ensuring their CLI tools are in sync with PowerShell authentication actions.


Motivation

Currently, users who authenticate via PowerShell functions must manually ensure that their gh and Git environments are configured to match. This manual process is error-prone and inconvenient, especially in multi-account or automation scenarios.


Proposal

New Behavior

  • On connect:
    When a user runs Connect-GitHubAccount or Connect-GitHubApp, the module should configure the GitHub CLI (gh) and Git to use the authenticated account (unless skipped).
  • On disconnect:
    When a user runs Disconnect-GitHubAccount, the module should clear (or restore) the related gh and Git context (unless skipped).

New Parameters

  • -SkipGit
    Skip Git configuration.
  • -SkipCli
    Skip GitHub CLI (gh) configuration.

Supported Functions

  • Connect-GitHubAccount
  • Connect-GitHubApp
  • Disconnect-GitHubAccount

Example Usage

Connect-GitHubAccount -SkipGit       # Configures only gh, not Git
Connect-GitHubAccount -SkipCli       # Configures only Git, not gh
Connect-GitHubAccount -SkipGit -SkipCli  # Skips all configuration (current behavior)

Disconnect-GitHubAccount             # Resets gh and Git context

Considerations

  • For Git, update user.name and user.email based on the authenticated GitHub user, scoped appropriately (global/local).
  • For gh, log in/out or switch user/context based on the account used in the session.
  • Should not override user settings unless the authentication context is explicitly changed via the cmdlet.

Acceptance Criteria

  • Cmdlets update Git and gh configuration according to the authenticated account.
  • -SkipGit and -SkipCli work as described.
  • Documentation/examples are updated to cover the new options.
  • Does not break existing behavior when both switches are omitted.

Additional Notes

  • Should gracefully handle environments where either git or gh are not installed.
  • Consider modularizing config logic for easier testing/maintenance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions