Problem/Motivation

composer/Plugin/Scaffold/ManageGitIgnore.php generates a .gitignore file which ignores files in the whole project. In my case I had a .eslintrc.json in a custom theme which was ignored. By adding a leading slash, this should be fixed

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

martijn.cuppens created an issue. See original summary.

martijn.cuppens’s picture

StatusFileSize
new601 bytes
jeroent’s picture

Status: Active » Needs review
jeroent’s picture

Version: 9.1.x-dev » 9.0.x-dev
jeroent’s picture

Title: Only add root files to gitignore » Scaffolding: Only add root files to gitignore
martijn.cuppens’s picture

StatusFileSize
new1.66 KB

Status: Needs review » Needs work

The last submitted patch, 6: 3115624-5.patch, failed testing. View results

martijn.cuppens’s picture

StatusFileSize
new1.59 KB
jeroent’s picture

Status: Needs work » Needs review
jungle’s picture

Assigned: Unassigned » jungle
Status: Needs review » Needs work

should add leading / to build too and update test(s)

martijn.cuppens’s picture

martijn.cuppens’s picture

StatusFileSize
new2.23 KB
martijn.cuppens’s picture

Aha, there was already a .gitignore file somewhere. I was wondering where that build folder was coming from.

jungle’s picture

Assigned: jungle » Unassigned
Status: Needs work » Needs review
StatusFileSize
new2.2 KB
new2.27 KB

Cool, you're quick!

Added a newline at end of file to file

core/tests/Drupal/Tests/Composer/Plugin/Scaffold/fixtures/drupal-composer-drupal-project/docroot/.gitignore
martijn.cuppens’s picture

Initially had that too, but then I removed it since we might also need to test the case where we don't have a newline at end of file?

jungle’s picture

StatusFileSize
new551 bytes

Sorry, a wrong interdiff attached, corrected.

jungle’s picture

Initially had that too, but then I removed it since we might also need to test the case where we don't have a newline at end of file?

Yes, maybe adding it is off the topic here, let's wait for others to give a comment. :p

jeroent’s picture

Status: Needs review » Reviewed & tested by the community

Patch looks sane to me.

mile23’s picture

To me the principle should be: If you scaffold a file, you can say whether to add that specific file to .gitignore.

If you scaffold [web-root]/arbitrary/path/robots.txt, then you should be able to add /arbitrary/path/robots.txt to [web-root]/.gitignore, with the leading slash so it's that one file being ignored.

If that's the desired behavior, then we need a test of whether the patch does that for subdirectories.

Set to NR because I think maybe @greg.1.anderson should chime in.

greg.1.anderson’s picture

Status: Needs review » Reviewed & tested by the community

Yes, this is exactly right -- and exactly how we should have written it the first time.

The scaffold tool first asks git if the file being scaffolded has been ignored; you can ignore it via whatever conventions you wish, and so long as it is ignored, the scaffold tool will not add its own entry for that file anywhere.

If the file is not ignored, and the scaffold tool is configured to ignore scaffold files, then it is better for it to add the leading slash so that other similarly-named files deeper in the hierarchy are not also ignored.

I tend to think that the current level of testing is fine. Now that we are adding the leading slash, I feel it is overkill to have a test that checks to see if `git check-ignore` respects the slash for subdirectories. I think the existing unit tests that check to see that the .gitignore contents are correct are sufficient without adding said functional tests.

Thanks for fixing this.

martijn.cuppens’s picture

alexpott’s picture

Version: 9.0.x-dev » 8.8.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed and pushed e3e5937d5c to 9.0.x and 2784f6a4b7 to 8.9.x. Thanks!

  • alexpott committed e3e5937 on 9.0.x
    Issue #3115624 by martijn.cuppens, jungle, JeroenT, greg.1.anderson,...

  • alexpott committed 2784f6a on 8.9.x
    Issue #3115624 by martijn.cuppens, jungle, JeroenT, greg.1.anderson,...
alexpott’s picture

Will backport to 8.8.x once the freeze is over.

alexpott’s picture

Status: Patch (to be ported) » Fixed

As this is a bugfix to non-runtime code backpotted to 8.8.x as it is not risky.

  • alexpott committed 067348c on 8.8.x
    Issue #3115624 by martijn.cuppens, jungle, JeroenT, greg.1.anderson,...

Status: Fixed » Closed (fixed)

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