Skip to content

fix: preserve migration order when files are moved to a new directory#22

Merged
mergify[bot] merged 1 commit into
mainfrom
devs/jd/worktree-mv/If7889abdfcfb21dfeaaf5377c613f8deb2374cc3
Mar 31, 2026
Merged

fix: preserve migration order when files are moved to a new directory#22
mergify[bot] merged 1 commit into
mainfrom
devs/jd/worktree-mv/If7889abdfcfb21dfeaaf5377c613f8deb2374cc3

Conversation

@jd

@jd jd commented Mar 31, 2026

Copy link
Copy Markdown
Member

When all migrations are moved to a new directory in a single commit,
git log --diff-filter=A with a pathspec restricted to the new
directory only sees the move commit as the one that "added" the files.
Within that single commit, git outputs filenames alphabetically,
losing the original chronological add order.

Fix by removing the pathspec so git scans the full repo history.
The original add commits (in the old directory) appear first, so
each file's first occurrence preserves its true creation order.
Results are filtered against files that currently exist in the
versions directory so unrelated files are excluded.

When all migrations are moved to a new directory in a single commit,
`git log --diff-filter=A` with a pathspec restricted to the new
directory only sees the move commit as the one that "added" the files.
Within that single commit, git outputs filenames alphabetically,
losing the original chronological add order.

Fix by removing the pathspec so git scans the full repo history.
The original add commits (in the old directory) appear first, so
each file's first occurrence preserves its true creation order.
Results are filtered against files that currently exist in the
versions directory so unrelated files are excluded.

Change-Id: If7889abdfcfb21dfeaaf5377c613f8deb2374cc3
Claude-Session-Id: dfe05075-9a44-4939-b789-53bacb722af4
@mergify
mergify Bot deployed to Mergify Merge Protections March 31, 2026 09:08 Active
@jd
jd marked this pull request as ready for review March 31, 2026 09:08
@mergify
mergify Bot requested a review from a team March 31, 2026 09:09
@mergify

mergify Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 🤖 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success=all-greens

🟢 👀 Review Requirements

Wonderful, this rule succeeded.
  • any of:
    • #approved-reviews-by>=1
    • author = dependabot[bot]
    • author = mergify-ci-bot

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?:

🟢 🔎 Reviews

Wonderful, this rule succeeded.
  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

@mergify

mergify Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-03-31 09:11 UTC · Rule: default
  • Checks skipped · PR is already up-to-date
  • Merged2026-03-31 09:11 UTC · at 11eb4c5d9de06b075602351f4ac454e6e9abc933

This pull request spent 9 seconds in the queue, including 1 second running CI.

Required conditions to merge

@mergify
mergify Bot merged commit f94142c into main Mar 31, 2026
9 checks passed
@mergify
mergify Bot deleted the devs/jd/worktree-mv/If7889abdfcfb21dfeaaf5377c613f8deb2374cc3 branch March 31, 2026 09:11
mergify Bot pushed a commit that referenced this pull request May 4, 2026
…er (#24)

v6 dropped the `-- versions/` pathspec from `_get_git_commit_order()` so
that migrations moved to a new directory keep their original add order.
Without the pathspec, git also walks feature-branch ancestors that
survive merge — so a migration whose feature commit is reachable from
HEAD gets that early commit's date as its sequence, even when another
migration was committed on main first.

That broke the engine deploy in INC-1342: a migration whose feature
branch was merged with `--no-ff` (Apr 30 feature commit, May 4 merge)
was placed before a migration committed directly on main on May 4 11:50,
inverting the on-main order and breaking the append-only check.

Add `--first-parent` so the walk stays on the integration branch and
never enters feature-branch ancestors. PR #22's directory-move scenario
still works because the original add commits are on main's first-parent
line (they were merged before the move). Verified end-to-end against the
mergify monorepo: chain head extends correctly from the previous deploy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants