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

[FEATURE] add support for inner .gitignore files #9646

Open
rtm-ctrlz opened this issue Jan 26, 2021 · 0 comments
Open

[FEATURE] add support for inner .gitignore files #9646

rtm-ctrlz opened this issue Jan 26, 2021 · 0 comments
Labels
Milestone

Comments

@rtm-ctrlz
Copy link
Contributor

Currently (2.0.8) composer support only top-level .gitignore file, but git allows to use .gitignore files at any level.

Proposal: add support for .gitignore at any level, not just top-level

Test case uses mirroring, but it applies to any handling of .gitignore

# initial state
$ find . -mindepth 1 | sort
./lib
./lib/composer.json
./lib/static
./lib/static/.gitignore
./lib/static/this-file-project-should-not-have
./project
./project/composer.json

# dumping files, any other files are empty
$ cat lib/composer.json
{
    "name": "gitignore-issue/lib",
    "type": "library",
    "minimum-stability": "dev",
    "require": {}
}
$ cat lib/static/.gitignore
/static-file-project-should-not-have

$ cat project/composer.json
{
    "name": "gitignore-issue/project",
    "type": "project",
    "minimum-stability": "dev",
    "require": {
        "gitignore-issue/lib": "*"
    },
    "repositories": [
        {
            "type": "path",
            "url": "../lib",
            "options": {
                "symlink": false
            }
        }
    ]
}

# doing install
$ cd project/
$ composer update
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
  - Locking gitignore-issue/lib (dev-master)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing gitignore-issue/lib (dev-master): Mirroring from ../lib
Generating autoload files

# checking result
$ cd ..
$ find . -mindepth 1 | sort
./lib
./lib/composer.json
./lib/static
./lib/static/.gitignore
./lib/static/this-file-project-should-not-have
./project
./project/composer.json
./project/composer.lock
./project/vendor
./project/vendor/autoload.php
./project/vendor/composer
# there were some composer files
./project/vendor/gitignore-issue
./project/vendor/gitignore-issue/lib
./project/vendor/gitignore-issue/lib/composer.json
./project/vendor/gitignore-issue/lib/static
./project/vendor/gitignore-issue/lib/static/.gitignore
./project/vendor/gitignore-issue/lib/static/this-file-project-should-not-have

Case above shows only exclusion of sub-file, but with .gitignore there is a way to "un-exclude file/dirs excluded by files on higher levels".

Actual result: project have file ./project/vendor/gitignore-issue/lib/static/this-file-project-should-not-have

Expected result: project doesn't have file ./project/vendor/gitignore-issue/lib/static/this-file-project-should-not-have. Reason for this this file is ignored by ./lib/static/.gitignore

composer update -vvv output
$ composer update -vvv
Reading ./composer.json
Loading config file /Users/user/.composer/config.json
Loading config file /Users/user/.composer/auth.json
Loading config file ./composer.json
Checked CA file /usr/local/etc/openssl@1.1/cert.pem: valid
Executing command (/private/tmp/test/project): git branch -a --no-color --no-abbrev -v
Executing command (/private/tmp/test/project): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/private/tmp/test/project): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/private/tmp/test/project): hg branch
Executing command (/private/tmp/test/project): fossil branch list
Executing command (/private/tmp/test/project): fossil tag list
Executing command (/private/tmp/test/project): svn info --xml
Reading /Users/user/.composer/composer.json
Loading config file /Users/user/.composer/config.json
Loading config file /Users/user/.composer/auth.json
Loading config file /Users/user/.composer/composer.json
Loading config file /Users/user/.composer/auth.json
Reading /Users/user/.composer/auth.json
Reading /Users/user/.composer/vendor/composer/installed.json
Running 2.0.8 (2020-12-03 17:20:38) with PHP 7.4.14 on Darwin / 19.6.0
Loading composer repositories with package information
Executing command (/private/tmp/test/lib/): git branch -a --no-color --no-abbrev -v
Executing command (/private/tmp/test/lib/): git describe --exact-match --tags
Executing command (/private/tmp/test/lib/): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/private/tmp/test/lib/): hg branch
Executing command (/private/tmp/test/lib/): fossil branch list
Executing command (/private/tmp/test/lib/): fossil tag list
Executing command (/private/tmp/test/lib/): svn info --xml
Updating dependencies
Generating rules
Resolving dependencies through SAT
Looking at all rules.

Dependency resolution completed in 0.000 seconds
Analyzed 108 packages to resolve dependencies
Analyzed 108 rules to resolve dependencies
Lock file operations: 1 install, 0 updates, 0 removals
Installs: gitignore-issue/lib:dev-master
  - Locking gitignore-issue/lib (dev-master)
Writing lock file
Installing dependencies from lock file (including require-dev)
Reading ./composer.lock
Package operations: 1 install, 0 updates, 0 removals
Installs: gitignore-issue/lib:dev-master
  - Installing gitignore-issue/lib (dev-master): Mirroring from ../lib
Generating autoload files
composer diagnose
$ composer diagnose
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 2.0.8
PHP version: 7.4.14
PHP binary path: /usr/local/Cellar/php@7.4/7.4.14_1/bin/php
OpenSSL version: OpenSSL 1.1.1i  8 Dec 2020
cURL version: 7.75.0-DEV libz 1.2.11 ssl (SecureTransport) OpenSSL/1.1.1i
zip: extension present, unzip present
@Seldaek Seldaek added this to the Nice To Have milestone Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants