Archive "exclude" option is broken: Cannot exclude recursively #2739

Closed
DHager opened this Issue Feb 21, 2014 · 3 comments

Comments

Projects
None yet
3 participants

DHager commented Feb 21, 2014

The documentation is either incorrect or the feature is broken.

exclude: Allows configuring a list of patterns for excluded paths. The pattern syntax matches .gitignore files.

This is not true with version aa74818fe00c5f5eb57c1c38b807e9e2950c670c dated 2014-02-21 15:53:59.

Consider a simple project with a fresly git inited repository:

$ tree .

.
├── composer.phar
├── composer.json
├── src
│   ├── file1.txt
│   └── file2.txt
└── test
    ├── fileA.txt
    └── fileB.txt

$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       composer.phar
#       composer.json
#       src/
#       test/

I now add a .gitignore file, containing:

/test

And it entirely blocks git from asking me to check in the tests directory, which is my intent.

$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       .gitignore
#       composer.phar
#       composer.json
#       src/

By comparison, let's try running the archive command using thiscomposer.json file:

{
    "name":             "test/archive-exclude-issue",
    "description":      "test",

    "archive": {
        "exclude": [ "/test" ]
    }
}

But... what's this! The test files still got included!

$ tar --list -f test-archive-exclude-issue-1.0.0.tar
composer.phar
src/file2.txt
src/file1.txt
test/fileA.txt
test/fileB.txt
.gitignore
composer.json

If someone decides that this is a misleading-documentation problem, then I'd still like to know: How exactly do I tell Composer to recursively exclude a directory when making archives?

@Seldaek Seldaek added the Bug label Feb 23, 2014

@Seldaek Seldaek added this to the Bugs milestone Feb 23, 2014

Owner

Seldaek commented Feb 23, 2014

You can try to workaround using just "test" but anyway it sounds like a bug.

DHager commented Feb 24, 2014

I suspect the folder itself is being excluded, but then something inside (which isn't explicitly blocked by another rule) is causing it to be created as a prerequisite.

sndpl pushed a commit to sndpl/composer that referenced this issue Feb 27, 2014

Sandy Pleyte
Fix for #2739 (and #1755), added support for directory excludes in th…
…e .gitignore file like /directory or directory/
Contributor

sndpl commented Feb 27, 2014

The problem was that the /test was converted to '#^/(?=[^.])test$#' And because of the $ sign at the end the files in the directory didn't match so it includes them in the archive. Added a PR with a fix for this and added some extra tests for #1755

Seldaek added a commit that referenced this issue Mar 23, 2014

Merge pull request #2769 from sndpl/issue/2739
Fix for #2739 (and #1755), added support for directory excludes in the gitignore file

@Seldaek Seldaek closed this Mar 23, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment