Problem/Motivation

The core-composer-scaffold plugin has the capability to manage .gitignore files for scaffolded files. This feature can be enabled or disabled in the top-level composer.json file. If it is neither enabled or disabled, then the default value is that the feature auto-disables if the current project is not managed in a git repository, or if the vendor directory has been committed already, and is otherwise enabled.

The default behavior presents a problem for the composer create-project command, because in this instance, there is always a git repository for the new site on the first run of the scaffold operation (create-project asks at the very end if the repository should be kept or removed), but it will never be the case that the vendor directory will be committed. The result is that the user ends up with a collection of .gitignore files, whether they wanted them or not.

Currently, the only way around this is to ensure that all of the initial scaffold files are .gitignored in the source project.

Proposed resolution

We can avoid this problem if we invert the default behavior of the .gitignore management feature:

  • Management of .gitignore files is disabled by default.
  • If the user has proactively .gitignored the vendor directory (and not explicitly enabled or disabled .gitignore management in composer.json), then the feature will be automatically enabled.

Remaining tasks

  • Change the code.
  • Update the Scaffold plugin README

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

n/a

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

greg.1.anderson created an issue. See original summary.

greg.1.anderson’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
739 bytes

Update issue summary with more accurate description of the problem, and upload a patch.

greg.1.anderson’s picture

Forgot to update README.

hussainweb’s picture

This LGTM. Two things:
- Does this need a CR? I checked previous change records and I didn't see this feature mentioned. I think a CR may not be strictly necessary.
- The documentation should be updated at https://www.drupal.org/docs/develop/using-composer/using-drupals-compose...

greg.1.anderson’s picture

Thanks; I updated the documentation page.

Since this bugfix is so minor, I thought few would have even noticed it at this point, and a CR was therefore superfluous. I'll write one up if anyone thinks it would be beneficial though.

hussainweb’s picture

Status: Needs review » Reviewed & tested by the community

Add to that, the feature is not out in a stable release yet, so I don't think a CR is necessary.

Thanks for updating the documentation.

mbaynton’s picture

Status: Reviewed & tested by the community » Needs review

Deconstructing this a bit so I can do an end-to-end create-project test with it in play. I was a little surprised to see this as a patch against Drupal and not a separate project for the scaffold plugin. Am I right that what that's about is someone said the authoritative copy needs to be in the One Drupal Source Tree, and so then it gets subtree split?

mbaynton’s picture

Status: Needs review » Reviewed & tested by the community

So that's weird, didn't intend to un-RTBC at this time.

greg.1.anderson’s picture

Yes, that's right: the source for the scaffold plugin is in the drupal/drupal git repository. The drupal.org infrastructure makes a subtree split from every directory in the repository that contains a composer.json file. Each of these split-out projects are exported under the "drupal" org on GitHub.

mbaynton’s picture

I tested this in combination with the issue that prompted it, #3082958: Add gitignore(s) to Composer-ready project templates, and confirmed that it fixes the issue. The scaffold plugin does not modify the pristine .gitignore from the project template that we're trying to supply as a starting state.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 2296602 and pushed to 8.8.x. Thanks!

  • alexpott committed 2296602 on 8.8.x
    Issue #3085354 by greg.1.anderson, mbaynton, hussainweb: Better default...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.