Skip to content

Handle missing Git in optional repo checks#7639

Merged
charlespwd merged 1 commit into
mainfrom
cp-user-friendly-git-not-found
May 26, 2026
Merged

Handle missing Git in optional repo checks#7639
charlespwd merged 1 commit into
mainfrom
cp-user-friendly-git-not-found

Conversation

@charlespwd
Copy link
Copy Markdown
Contributor

@charlespwd charlespwd commented May 26, 2026

Why

Some theme workflows use Git only as an optional safety check before continuing. When Git is not installed or unavailable on PATH, those checks should not surface raw command failures to users.

What changed

  • Treat missing Git as “not inside a Git directory” for optional repository detection.
  • Keep a friendly, actionable error for flows that explicitly require Git.
  • Added unit coverage for both behaviours.

Testing

  • pnpm vitest run packages/cli-kit/src/public/node/git.test.ts --config packages/cli-kit/vite.config.ts
  • pnpm vitest run packages/theme/src/cli/services/pull.test.ts --config packages/theme/vite.config.ts

Fixes shop/issues#47568

@charlespwd charlespwd marked this pull request as ready for review May 26, 2026 13:04
@charlespwd charlespwd requested a review from a team as a code owner May 26, 2026 13:04
Copilot AI review requested due to automatic review settings May 26, 2026 13:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the @shopify/cli-kit Git helpers so that optional repository checks don’t surface raw failures when git is missing from PATH, while flows that require Git still fail with a friendly, actionable error.

Changes:

  • Made insideGitDirectory() return false when Git is not available (treat as “not a repo” for optional checks).
  • Updated ensureInsideGitDirectory() to explicitly require Git first and then perform the repo check.
  • Added unit tests covering both “Git missing” behaviors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/cli-kit/src/public/node/git.ts Separates “Git required” vs “optional repo detection” behavior by gating required checks with ensureGitIsPresentOrAbort() and making optional checks return false when Git is absent.
packages/cli-kit/src/public/node/git.test.ts Adds unit tests ensuring missing-Git behavior is friendly for required flows and silent (false) for optional detection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@charlespwd charlespwd force-pushed the cp-user-friendly-git-not-found branch from efc3789 to 0ded558 Compare May 26, 2026 13:08
@charlespwd charlespwd requested a review from a team as a code owner May 26, 2026 13:08
@charlespwd charlespwd force-pushed the cp-user-friendly-git-not-found branch from 0ded558 to 5156580 Compare May 26, 2026 13:27
@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label May 26, 2026
Copy link
Copy Markdown
Contributor

@karreiro karreiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @charlespwd!

@charlespwd charlespwd enabled auto-merge May 26, 2026 13:36
@charlespwd charlespwd added this pull request to the merge queue May 26, 2026
Merged via the queue into main with commit 211ae41 May 26, 2026
29 checks passed
@charlespwd charlespwd deleted the cp-user-friendly-git-not-found branch May 26, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants