Skip to content

feat(Pull-SDLC): replace -SetupGitHubSsh with -SetupGit#172

Closed
MarkMichaelis wants to merge 1 commit into
fix/169-remove-ssh-nudgefrom
feat/171-setup-git
Closed

feat(Pull-SDLC): replace -SetupGitHubSsh with -SetupGit#172
MarkMichaelis wants to merge 1 commit into
fix/169-remove-ssh-nudgefrom
feat/171-setup-git

Conversation

@MarkMichaelis
Copy link
Copy Markdown
Contributor

Summary

Replaces the misguided -SetupGitHubSsh switch (added in #164, partially walked back in #170) with a focused -SetupGit that does what a per-repo sync script should actually do: scaffold repo-level git files. No more touching SSH keys, ssh-agent, machine-wide git settings, the gh CLI, or URL rewrites -- protocol choices stay with the user.

Per the discussion on #169, the old switch was wrong on two axes:

  1. Protocol is not the script's business. Whether a user connects to GitHub over HTTPS, SSH-22, or SSH-443 is a per-machine choice.
  2. GitHub-specific framing was too narrow. The pieces a fresh repo actually wants pre-configured are .gitignore and .gitattributes -- git configuration, not GitHub configuration. Hence -SetupGit, not -SetupGitHub.

What -SetupGit does

  1. .gitattributes: creates the file with a minimal line-ending normalization baseline (* text=auto eol=lf) when missing. Never overwrites an existing file.
  2. .gitignore: union-merges upstream entries into the consumer copy via the existing Merge-FileFromUpstream code path (the same one the normal sync uses).

Every step prints [skip] or [add] so the user sees exactly what changed.

Removed (breaking)

-SetupGitHubSsh was recent (#164) and the broader direction was already being walked back. Clean removal beats a deprecation alias:

  • -SetupGitHubSsh and -SkipKeyUpload parameters
  • Invoke-SetupGitHubSsh function
  • Helpers: Get-GitHubSshKeyPath, Test-GitHubSshAgentRunning, Test-GhInstalled, Get-GitConfigAllValues, Get-GhGitProtocol, Add-GitConfigValueIfMissing
  • 6 obsolete Pester Describe blocks covering the removed helpers

Tests added

  • Invoke-SetupGit behavior (5 tests): creates .gitattributes with the expected baseline when missing, leaves an existing .gitattributes alone, forwards the upstream ref correctly to Merge-FileFromUpstream, does not invoke ssh-keygen/gh/git config --global (contract guard), is idempotent.
  • Removal regression tests (4 tests) asserting the script no longer declares -SetupGitHubSsh/-SkipKeyUpload, no longer defines Invoke-SetupGitHubSsh, and contains no code references to git config --global, gh config set, ssh-keygen, or url.insteadOf. These are the real ratchet -- they fail loudly if anyone later re-adds protocol-level mutations.

Diff stats

2 files changed, +155 / -362. Net deletion of ~200 lines.

Stacked on

This PR is stacked on #170 (which removes the unsolicited drift nudge). Merge #170 first, then this PR will rebase cleanly onto main.

Verification

\\powershell
Invoke-Pester -Path .\Pull-SDLC.ai.Tests.ps1 -FullNameFilter '-SetupGit','Invoke-SetupGit','-SetupGitHubSsh removed','post-sync output'
\\

Local result: 10 passed, 0 failed. Broader subset (31 tests across ConvertTo-GitHubRepoSlug, Resolve-OpenSyncPRAction, Test-IsCiEnvironment, Test-IsUpstreamRepo, plus all new tests): 31 passed, 0 failed.

Closes #171

The previous -SetupGitHubSsh switch was wrong on two axes:

1. Protocol is not the script's business. Whether a user connects to
   GitHub over HTTPS, SSH-22, or SSH-443 is a per-machine choice and
   must not be silently rewritten by an instructions-sync script.
2. GitHub-specific framing was too narrow. The pieces a fresh repo
   actually wants pre-configured are .gitignore and .gitattributes --
   git configuration, not GitHub configuration.

This change replaces -SetupGitHubSsh with -SetupGit:

  - Idempotently creates .gitattributes with a minimal line-ending
    normalization baseline (`* text=auto eol=lf`) when missing.
    Never overwrites an existing file.
  - Union-merges the upstream .gitignore into the consumer copy via
    the existing Merge-FileFromUpstream code path.
  - Does NOT touch SSH keys, ssh-agent, machine-wide git settings,
    gh CLI configuration, or URL rewrites.

Removed (breaking; -SetupGitHubSsh was recent, from #164):
  - -SetupGitHubSsh and -SkipKeyUpload parameters
  - Invoke-SetupGitHubSsh function
  - Helpers: Get-GitHubSshKeyPath, Test-GitHubSshAgentRunning,
    Test-GhInstalled, Get-GitConfigAllValues, Get-GhGitProtocol,
    Add-GitConfigValueIfMissing
  - 6 obsolete Pester Describe blocks covering the removed helpers

Added tests:
  - Invoke-SetupGit behavior (5 tests): creation, non-overwrite of
    existing files, ref forwarding to Merge-FileFromUpstream,
    idempotency.
  - Contract-guard regression tests (4 tests) asserting the script
    no longer declares -SetupGitHubSsh/-SkipKeyUpload, no longer
    defines Invoke-SetupGitHubSsh, and contains no code references
    to global git config, gh config set, ssh-keygen, or url.insteadOf
    -- so future commits cannot quietly re-add protocol mutations.

Closes #171

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MarkMichaelis
Copy link
Copy Markdown
Contributor Author

Closing in favor of #161 (issue #160), which was opened ~4 hours before this PR and tackles the same scope with a substantially more thoughtful design:

  • Separate Initialize-GitDefaults.ps1 script rather than a switch on the sync script.
  • Language-aware composition (C#, PowerShell, TypeScript, ASP.NET).
  • Pinned community templates from alexkaratarakis/gitattributes and github/gitignore.
  • Bundled offline snapshots with pinned SHAs and SOURCES.md.
  • gibo ecosystem integration.

This PR was built in a session that didn't know about #161. Apologies for the duplicate work. The minimal * text=auto eol=lf baseline approach here doesn't add anything that the language-aware composition in #161 won't already cover.

The orthogonal "remove unsolicited drift nudge" fix is preserved in #170 (parent of this PR's branch) and will land independently.

Closes nothing -- issue #171 is being closed separately as superseded by #160.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant