Documentation
¶
Overview ¶
Package migrationgit answers, from git, the one question both the version lint and `forge db migration rebase` have to agree on: which migrations were already on the default branch when this branch was cut.
Both callers act on that answer, in opposite directions. The lint flags a migration as NEW — and therefore still fixable — when its version is above the merge-base high-water mark. Rebase REFUSES to re-version a migration that is at or below it and present on the default branch, because renaming one that has already merged breaks every database that recorded it.
Two implementations of that boundary would eventually disagree, and the disagreement would be silent: the lint would tell someone to rebase a file the rebase command would happily rename, or refuse one the lint had just flagged. One definition, in one place.
EVERY FAILURE HERE IS "UNKNOWN", NOT AN ERROR. This code runs in checkouts it does not control: a shallow CI clone, an exported tarball, a repository with no default branch, a migrations directory that is not tracked at all. A missing git binary is deliberately indistinguishable from a failed command, because both mean the same thing to a caller.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultBranchVersions ¶
DefaultBranchVersions returns the migration versions present in migrationsDir on the default branch's tip, mapped to the filename that claims each one.
The TIP, not the merge-base, because this answers "has this version already merged". A migration that landed on main after this branch was cut is just as merged as one that predates it, and renaming it is just as wrong.
func IsTracked ¶
IsTracked reports whether path is tracked by git, which decides whether a rename goes through `git mv` or a plain filesystem rename.
func MergeBaseMax ¶
MergeBaseMax returns the highest migration version present in migrationsDir as of the merge-base between HEAD and the default branch — the state this branch started from — and whether that could be determined at all.
Types ¶
This section is empty.