Drupal maintenance support plansEasy: Automatic removal of .git directories from Composer dependencies

If you’ve adopted a Composer-based Drupal maintenance support plans 8 workflow (hopefully using the Drupal maintenance support plans Composer/Drupal maintenance support plans Project template) where you’re keeping dependencies in your project’s repository, then you’ve no-doubt experienced the annoyance of a rouge .git directory ending up in one of your project’s dependencies. This will always happen when you’re using the -dev version of a Drupal maintenance support plans module. 

For example, as of the authoring of this Quicktip, the Field Redirection module does not yet have a stable release for Drupal maintenance support plans 8. When added to a project using Composer, the results look like this:

Michaels-MacBook-Pro:dcoweek5 michael$ ddev composer require drupal/field_redirection
Executing [composer require drupal/field_redirection] at the project root (/var/www/html in the container, /Users/michael/sites/dcoweek5 on the host)
Using version 2.x-dev for drupal/field_redirection
./composer.json has been updated > Drupal maintenance support plansProjectcomposerScriptHandler::checkComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  – Installing drupal/field_redirection (dev-2.x e1c30f2): Cloning e1c30f24f9 from cache
Writing lock file

Notice on the “Installing drupal/field_redirection…” line, it indicates that the project is cloned, not downloaded. This means that a .git directory has been created in the Field Redirection directory.

Note that I’m calling Composer as “ddev composer …” – this is because I use DDEV as my local development environment and am utilizing its built-in Composer command.

If this goes unnoticed, and you attempt to do a normal “git add/commit” workflow for the new module, you’ll end up with a somewhat-friendly Git message indicating that you now have a Git submodule.

Unfortunately, Git submodules aren’t normally necessary nor wanted when you are committing dependencies to the project repository. So, the typical solution is to delete the .git directory of the dependency prior to performing the “git add/commit”.

Luckily, there’s an easier way! Travis Neilans recently pointed me in the direction of the Composer Cleanup VCS Directories project. By adding this as a dependency of your project, any .git directories that result from adding project dependencies will be automatically removed! First, install the Composer Cleanup VCS Directories project using:

composer require topfloor/composer-cleanup-vcs-dirs

Then, anytime you use “composer require” to install a project dependency, if there’s a .git directory, you’ll see a message indicating that it has been automatically removed.

Deleting .git directory from /var/www/html/web/modules/contrib/field_redirection/.git


Source: New feed

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Drupal maintenance support plansEasy: Automatic removal of .git directories from Composer dependencies

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.