Skip to content

Allow gitlib 2 - #1235

Draft
lyrixx wants to merge 2 commits into
phpro:v2.xfrom
lyrixx:gitlib-2
Draft

lyrixx wants to merge 2 commits into
phpro:v2.xfrom
lyrixx:gitlib-2

Conversation

@lyrixx

@lyrixx lyrixx commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

gitlib 2.0 is about to be released. This PR checks that grumphp can upgrade to it, before the release.

gitlib 2 requires PHP 8.4, so grumphp supports ^1.6 || ^2.0: it uses the API of gitlib 2 when it's installed, without triggering its deprecations, and keeps the API of gitlib 1 otherwise.

Changes

  • GitRepositoryLocator configures the repository with a CliDriver (logger included) instead of the options array, deprecated in gitlib 2. inherit_environment_variables has no counterpart in gitlib 2: git inherits the environment variables of PHP anyway, and grumphp writes its own (Dotenv, paths) to $_ENV or with putenv(). GitRepository gets the logger instead of the options array.
  • GitRepository::createRawDiff() gives the repository to Diff::parse() with gitlib 2: Diff::setRepository() is deprecated there.
  • ChangedFiles names a file with File::getName(), which is the new name of a renamed file with both versions (getNewName() is nullable in gitlib 2).
  • The specs no longer double gitlib classes: Repository, WorkingCopy, Diff and Diff\File are final in gitlib 2. They run on temporary git repositories (GrumPHPTest\Helpers\TemporaryGitRepository) instead.
  • The raw diff fixture of the specs had spaces instead of a tab, and a modification status for a new file. gitlib 1 accepted it; gitlib 2 parses the raw information strictly and refuses it. The hooks send the real output of git, so they aren't affected.

The lock file is unchanged (gitlib 1.6.0, platform PHP 8.2), apart from its hash.

Testing before gitlib 2.0 is released

The last commit ([DO NOT MERGE]) installs the main branch of gitlib as 2.0.0 for the highest jobs on PHP 8.4 and 8.5, both in grumphp and in the projects the E2E tests create. It has to be dropped before merging: once 2.0 is released, these jobs install it on their own.

Locally, with gitlib 1.6.0 and with gitlib's main branch installed as 2.0.0:

Suite gitlib 1.6.0 gitlib 2.0.0 (main)
phpspec 386/386 386/386
PHPUnit Unit 1 failure, also on v2.x (XmlLinterTest with xinclude, depends on libxml) same
E2E (paratest) 23 passed, 2 skipped 23 passed, 2 skipped
psalm (PHP 8.4) no errors no errors

No deprecation of gitlib is triggered with gitlib 2.

gitlib 2 requires PHP 8.4, so grumphp supports both gitlib 1 and 2: it
uses the API of gitlib 2 when it's installed, without its deprecations.

- The repository is configured with a CliDriver instead of options. Its
  "inherit_environment_variables" option has no counterpart: git
  inherits the environment variables of PHP anyway, and Dotenv and the
  paths registrar write them to $_ENV or with putenv().
- The diff of the hooks is parsed with its repository.
- The changed files are named by File::getName(), the new name of a
  renamed file with both versions: getNewName() is nullable in gitlib 2.
- The specs no longer double the classes of gitlib, which are final in
  gitlib 2: they run on temporary git repositories instead.
- The raw diff of the specs had spaces instead of a tab, and the status
  of a modification for a new file: gitlib 2 refuses it.
To drop once gitlib 2.0 is released: the highest dependencies on PHP 8.4 and 8.5 then install it.

This branch has not been deployed

No deployments
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