Skip to content

Confirm before theme pull overwrites or deletes local files - #8859

Draft
PhilippeCollin wants to merge 2 commits into
mainfrom
theme-pull-skip-git-check
Draft

PhilippeCollin wants to merge 2 commits into
mainfrom
theme-pull-skip-git-check

Conversation

@PhilippeCollin

@PhilippeCollin PhilippeCollin commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

shopify theme pull overwrites local files with the remote version and deletes local files that don't exist remotely. The only protection against losing local work was a prompt shown when the target directory was a Git repository with uncommitted changes. That check ran Git inside the pull target, only covered Git directories, and didn't say which files would be affected.

WHAT is this pull request doing?

  • Before writing anything, theme pull now works out which existing local files it would overwrite or delete, lists them (up to 10, then "and N more"), and asks for confirmation.
  • Removes the uncommitted-changes check (and its Git invocation) that this replaces.
  • The file selection is shared with the downloader, so the prompt lists exactly the files the pull will change. New files that don't exist locally don't trigger the prompt.
  • --force skips the prompt. --nodelete keeps deletions out of it.
  • When prompting isn't possible (CI, no TTY, --no-input, multi-environment runs), the affected files are shown as a warning and the pull continues. This matches how the existing "not a theme directory" confirmation behaves in those cases, so CI pulls keep working.

Behaviour change for reviewers

The previous prompt only appeared for dirty Git trees. The new one appears whenever a pull would change existing local files, whether the change came from local edits or from the remote. That's more prompts for interactive users, in exchange for covering non-Git directories and showing exactly what will change.

How to test your changes?

  • pnpm vitest run packages/theme/src/cli/services/pull.test.ts packages/theme/src/cli/utilities/theme-ui.test.ts packages/theme/src/cli/utilities/theme-downloader.test.ts
  • Manually, in a theme directory: edit a local file that also exists remotely, run shopify theme pull, and check the file is listed and nothing changes if you decline. Run again with --force, and check there's no prompt.

🤖 Generated with Claude Code

`shopify theme pull` checked for uncommitted changes by running
`git status` in the target directory. Git reads its settings from
that directory, which isn't always trusted, so remove the check and
avoid invoking Git on the pull target entirely.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added the Area: @shopify/theme @shopify/theme package issues label Oct 9, 2026
List the local files a pull would overwrite or delete and ask for
confirmation before changing them. `--force` skips the prompt, and when
prompting isn't possible the files are listed as a warning and the pull
continues, matching the existing directory confirmation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PhilippeCollin PhilippeCollin changed the title Don't run Git in the target directory during theme pull Confirm before theme pull overwrites or deletes local files Oct 9, 2026

This branch has not been deployed

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

Labels

Area: @shopify/theme @shopify/theme package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant