Download the PHP package cromero/composer-mr-patches-commit-lock without Composer
On this page you can find all versions of the php package cromero/composer-mr-patches-commit-lock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cromero/composer-mr-patches-commit-lock
More information about cromero/composer-mr-patches-commit-lock
Files in cromero/composer-mr-patches-commit-lock
Package composer-mr-patches-commit-lock
Short Description Composer plugin to lock Drupal.org MR patch commits in composer.lock
License BSD-3-Clause
Informations about the package composer-mr-patches-commit-lock
Composer Patches Commit Lock
A Composer plugin that extends cweagans/composer-patches to lock Git patch commits from various providers (Drupal.org, GitHub, GitLab, etc.) in composer.lock.
Problem
When using patches from Git hosting providers (Drupal.org MRs, GitHub PRs, GitLab MRs), the patch URL often returns the latest version of the patch. If a new commit is pushed to the branch, the patch content changes.
This causes issues during deployment:
- If your
composer.lockhas the old patch content, a new deploy will fail - If you don't have a lock file, the new patch code gets applied unexpectedly
Solution
This plugin:
- Detects Git patch URLs from supported providers
- Fetches the commit hash from the provider's API
- Downloads the patch for that specific commit
- Stores the commit hash and provider in
composer.lockunderpatch-commit-locksection - On subsequent installs, uses the locked commit hash to download the exact same patch
Installation
Make sure you also have cweagans/composer-patches installed:
Usage
Define your patches as usual in composer.json:
How it works
Automatic lock on install/update
The plugin automatically checks if all git.drupalcode.org patches are locked in composer.lock when you run:
If any patches are missing from the lock, it will:
- Fetch the commit hash from GitLab API
- Save it to
composer.lockunderpatch-commit-lock - Continue with the normal install/update process
Example output:
Manual lock commands
Lock all patches
Scans all git.drupalcode.org patches in composer.json and locks their commit hashes to composer.lock.
Lock a single patch
Set a specific commit hash
Example:
This is useful when you need to lock to a specific commit that is not the latest one. The command:
- Validates the URL is from a supported provider
- Validates the commit hash format (7-40 hex characters)
- Verifies the commit exists on the remote
- Saves to
composer.lock
Get commit hash for a patch (testing)
Supported Providers
| Provider | URL Pattern | Identifier |
|---|---|---|
| Drupal.org (GitLab) | https://git.drupalcode.org/project/{project}/-/merge_requests/{mr}.patch |
drupal-gitlab |
| Drupal.org (issues) | https://www.drupal.org/files/issues/{date}/{issue}.patch |
drupal-gitlab |
| GitHub PR | https://github.com/owner/repo/pull/123.patch |
github |
| GitHub (patch-diff) | https://patch-diff.githubusercontent.com/raw/owner/repo/pull/123.patch |
github |
| GitHub Commit | https://github.com/owner/repo/commit/abc123.patch |
github |
Example composer.lock output
Commands Reference
| Command | Description |
|---|---|
composer patches:lock-commits |
Lock all git.drupalcode.org patches to composer.lock |
composer patches:lock-commit <url> |
Lock a single patch to composer.lock |
composer patches:set-commit <url> <hash> |
Set a specific commit hash for a patch |
composer patches:mr-commit <url> |
Fetch and display commit hash (testing) |
Extending with Custom Providers
Create a custom provider by implementing GitProviderInterface or extending AbstractGitProvider:
Requirements
- PHP 8.1+
- Composer 2.x
- cweagans/composer-patches ^2.0
- Internet access to provider APIs
License
BSD-3-Clause
All versions of composer-mr-patches-commit-lock with dependencies
ext-json Version *
composer-plugin-api Version ^2.0
cweagans/composer-patches Version ^2.0