Created
December 1, 2023 10:25
-
-
Save joachim-n/4f1c046d61a68384c416eb806a904249 to your computer and use it in GitHub Desktop.
Script for switching a project to use a git clone of a Drupal contrib module
This file contains 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
#!/usr/bin/env bash | |
# Script for switching a project to use a git clone of a Drupal contrib module. | |
if [ ! -d repos/$1 ]; then | |
# Get the version of the module that the project currently has installed | |
# so we can clone the same version. This ensures that Composer will accept to | |
# install it. | |
VERSION=`php -r "require_once 'vendor/autoload.php'; print \Composer\InstalledVersions::getReference('drupal/$1');"` | |
# Create a git clone. | |
cd repos | |
git clone -b $VERSION https://git.drupalcode.org/project/$1.git | |
cd .. | |
fi | |
# Add a Composer path repository that points to the git clone. | |
composer config repositories.$1 path repos/$1 | |
# Switch the project to use the git clone. | |
composer require drupal/$1 '*' | |
# You can now go to the git clone and switch to a feature branch. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment