Skip to content

Commit 5be0a71

Browse files
Fix git checkout error when switching to pr-screenshot branch
The script was failing with "Your local changes to the following files would be overwritten by checkout" because: - Screenshot tests run with --update-goldens, which modifies files in test/screenshots/goldens/ - These files are then copied to a temp directory - When attempting to checkout pr-screenshot branch, git refuses due to uncommitted local changes Fixed by using `git checkout -f` (force) to discard local changes when switching branches. This is safe because: - Screenshots are already copied to temp directory before checkout - The modified golden files are test artifacts, not production code - We want to switch to the clean pr-screenshot branch regardless of local changes This allows the workflow to successfully commit screenshots to the pr-screenshot branch. Co-authored-by: richardthe3rd <573334+richardthe3rd@users.noreply.github.com>
1 parent 77ce2ae commit 5be0a71

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

scripts/update_screenshot_branch.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ git config --local user.name "github-actions[bot]"
4242
if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then
4343
echo "Branch $BRANCH_NAME exists, checking it out..."
4444
git fetch origin "$BRANCH_NAME"
45-
git checkout "$BRANCH_NAME"
45+
46+
# Force checkout to discard local changes in test/screenshots/goldens/
47+
# (screenshots are already copied to temp directory)
48+
git checkout -f "$BRANCH_NAME"
4649

4750
# Pull latest changes
4851
git pull origin "$BRANCH_NAME"

0 commit comments

Comments
 (0)