Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove .git folder from modules and themes development branches #223

Closed
ndf opened this issue Nov 30, 2016 · 10 comments

Comments

Projects
None yet
9 participants
@ndf
Copy link

commented Nov 30, 2016

When requiring a development branch of a Drupal module or theme, the repository will be downloaded as git repository.

Example
composer require drupal/paragraphs:1.x-dev
composer install
Result
web/modules/contrib/paragraphs/.git/...
web/modules/contrib/paragraphs/paragraphs.info.yml

Can we add a post-install-cmd and post-update-cmd event that removes these .git folders?

@PatrickBauer

This comment has been minimized.

Copy link

commented Nov 30, 2016

Actually you shouldn't commit these contrib modules (thats why they are inside the .gitignore). If you really need them, you could implement a post-update-command for your project, but I don't think it should be the default.

@fafnirical

This comment has been minimized.

Copy link

commented Nov 30, 2016

Unfortunately, some hosting providers (like Acquia) seem to require git deployments. Because of the git metadata, those packages can't be added for the deployment, even with git add --force.

For our Composer-managed, Acquia-hosted projects, we're removing the folders only on our CI server.

@ndf

This comment has been minimized.

Copy link
Author

commented Dec 1, 2016

@PatrickBauer Ah your right. I noticed this in a project where we deviated from the default behaviour and actually committed all composer dependencies.

That case looks like @fafnirical with Acquia, because a Composer deployment isn't supported.
We remove the .git directories for submodules manually before committing.

So I am with @PatrickBauer that this feature-request should not be default.
Additionally; if we do create this feature, I guess it should be extended to all composer dependencies, not limited the drupal modules/themes.

How do you think about this?

@cmcintosh

This comment has been minimized.

Copy link

commented Dec 1, 2016

@ndf

This comment has been minimized.

Copy link
Author

commented Dec 6, 2016

@cmcintosh Hard to say if there is an 'ideal' workflow. But I guess it is safe to say that a lot of projects are moving from 'one big file dump' (ftp) to 'big file dump in version control' (git) to 'only saving meta-data about dependencies'.

In Drupal-land the latter was previously managed with 'drush make', and that is going towards 'composer'.
In JS-land this is done with NPM and in Ruby-land with Bundler.

A big plus for this workflow is that the dependency-management tool (composer, npm, bundler) takes care of updating your dependencies and patches. It makes maintenance easier when a project evolves.

In reality, as @fafnirical said, not all hosting providers support all workflows. So that is something to consider too.

@tanc

This comment has been minimized.

Copy link

commented Dec 12, 2016

We're currently wedded to a monolithic repo method so to handle development modules with git directories we just remove them with an additional function in scripts/composer/ScriptHandler.php

  public static function removeGitDirectories() {
    $root = static::getDrupalRoot(getcwd());
    exec('find ' . $root . ' -name \'.git\' | xargs rm -rf');
  }

This gets called in our composer.json in post-install-cmd and post-update-cmd

"post-install-cmd": [
    "DrupalProject\\composer\\ScriptHandler::createRequiredFiles",
    "DrupalProject\\composer\\ScriptHandler::removeGitDirectories"
],
"post-update-cmd": [
    "DrupalProject\\composer\\ScriptHandler::createRequiredFiles",
    "DrupalProject\\composer\\ScriptHandler::removeGitDirectories"
]

It's a bit brutal but it works. One side effect is that when you composer update a development module it will complain but you can just hit return to force update it.

@webflo

This comment has been minimized.

Copy link
Member

commented Jan 30, 2017

The snippet looks good, thanks for sharing. 👍

@webflo webflo closed this Jan 30, 2017

@Natshah

This comment has been minimized.

Copy link

commented Aug 8, 2017

Thank you :) 👍 using ....

@weitzman

This comment has been minimized.

Copy link
Collaborator

commented Aug 8, 2017

One side effect is that when you composer update a development module it will complain but you can just hit return to force update it.

Another way to bypass that warning is to add --no-interaction option.

@mqanneh

This comment has been minimized.

Copy link

commented Nov 22, 2017

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.