8000 link-fixtures: fetch before moving to master, and refuse to discard local work by irfan-dahir · Pull Request #683 · jikan-me/jikan · GitHub
[go: up one dir, main page]

Skip to content

link-fixtures: fetch before moving to master, and refuse to discard local work - #683

Merged
irfan-dahir merged 1 commit into
masterfrom
chore/link-fixtures-fetch
Nov 12, 2026
Merged

irfan-dahir merged 1 commit into
masterfrom
chore/link-fixtures-fetch

Conversation

@irfan-dahir
Copy link
Copy Markdown
Collaborator

Two bugs in one line of composer.json:

"git clone … || git -C ../jikan-fixtures reset --hard origin/master"
  1. No fetch. An existing clone kept its stale origin/master, so the local recordings could disagree with what CI installs. That happened for real: a local clone sat on a month-old ref and on a feature branch, which made a baseline run look different from CI for no code reason.
  2. reset --hard destroys uncommitted work. Any recording or snapshot in progress is silently discarded — the failure mode is invisible until you notice the files are gone.

The fix

scripts/link-fixtures.php, called as the first step of the composer script:

  • clone if ../jikan-fixtures is absent;
  • otherwise fetch --prune origin, checkout master, merge --ff-only origin/master;
  • refuse (exit 1, clear message) if the clone has uncommitted changes.

PHP rather than a shell script because tests.yaml runs composer run-script link-fixtures on windows-latest too, where sh is not guaranteed to be on PATH.

Verification

  • Clean clone: link-fixtures: ../jikan-fixtures is on master at 7dfcc70 (was stale, now sits on current master).
  • Dirty clone: link-fixtures: ../jikan-fixtures has uncommitted changes; commit or stash them first. and exit 1.
  • Full composer link-fixtures end-to-end: fetches, symlinks vendor/jikan-me/jikan-fixtures, composer update resolves the new reference.

No behaviour change for a fresh checkout; the difference is only that an existing one is brought up to date safely.

The script was `git clone … || git -C ../jikan-fixtures reset --hard
origin/master`: no fetch, so an existing clone could stay on a month-old
ref and disagree with CI about which recordings exist, and the hard reset
destroyed uncommitted recordings and snapshots silently.

A small PHP script now fetches, checks out master, fast-forwards, and
refuses to touch a clone that has uncommitted changes. PHP is used rather
than a shell script so the Windows CI runners run it too.
@irfan-dahir
irfan-dahir merged commit dbd56b3 into master Nov 12, 2026
6 checks passed
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

0