Repository navigation
Prepare the upgrade to 2.0 (1.7) - #264
Merged
Merged
Conversation
1.7 has the API of 2.0 that can be added without breaking 1.x, and deprecates what 2.0 replaces or breaks, with the messages of 2.0: code without deprecations with 1.7 runs with 2.0 too, so a library can require "^1.7 || ^2.0" with a single code path. 1.7 breaks nothing of 1.6: the parameters keep their names, the arguments added to the methods of classes that aren't final are read with func_get_arg(), and gitlib keeps calling the deprecated methods a subclass overrides. It requires PHP 8.1, for the DiffLineType enum, and symfony/deprecation-contracts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gitlib 1.7 prepares the upgrade to 2.0, the way Symfony prepares its majors: it has the API of 2.0 that can be added without breaking 1.x, and deprecates what 2.0 replaces or breaks, with the messages of 2.0. Code without deprecations with 1.7 runs with 2.0 too, so a library can require
^1.7 || ^2.0with a single code path. With it, phpro/grumphp#1235 drops itsclass_exists()branches and its Psalm suppressions.The
CHANGELOG.mdlists everything. In short:CliDriverandnew Repository($dir, $workingDir, $driver), the static methods ofRepository(init(),cloneFrom()…) instead ofAdmin;getDiff($from, $to),getMergeBase(),Diff::parse($raw, $repository),FileChange::getDiffLines()withDiffLineand theDiffLineTypeenum;Tree, which givesTreeEntryobjects, withgetBlobs(),getTrees()andgetSubmodules();Log::withLimit(),Blame::getHunks(),Branch::isMergedInto()andmoveTo(),PushReference::isCreation(),getSizeInBytes()…Nothing of 1.6 breaks
The aim is that upgrading from 1.6 to 1.7 is safe, so it follows the BC promise of Symfony, and is stricter on parameter names:
func_get_arg(), commented out in their signature, with@psalm-variadic, so the classes overriding these methods keep working;@final since gitonomy/gitlib 1.7.BackwardCompatibilityTestchecks these. The test suite ofv1.6.0, unchanged, passes on this code, except 3 tests:testGetSize, which fails onv1.6.0already with git 2.53, and 2 tests whose error handler refuses any deprecation but the one they expect.1.7 requires PHP 8.1, for the
DiffLineTypeenum: on PHP 8.0, Composer keeps 1.6. It requiressymfony/deprecation-contracts.What 1.7 can't bring
A few changes of 2.0 would break 1.x. They will be listed in the
UPGRADE-2.0.mdofmain: the numbering ofBlame::getLines()with a range, reading the references again afterrun(),\DateTimeImmutabledates, the stricter diff parser…Next steps
v1.7.0on1.x.1.xintomainwithgit merge -s ours:mainkeeps its tree and gets 1.7 as an ancestor, with no force push.mainso that 2.0 introduces no deprecation of its own (all are since 1.7), with the "Supporting 1.x and 2.x" section ofUPGRADE-2.0.md.