Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
DHager opened this Issue · 3 comments

3 participants

@DHager

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
@Seldaek Seldaek added this to the Bugs milestone
@Seldaek
Owner

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

@DHager

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 sndpl referenced this issue from a commit in sndpl/composer
@sndpl sndpl Fix for #2739 (and #1755), added support for directory excludes in th…
…e .gitignore file like /directory or directory/
21109ad
@sndpl

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 Seldaek closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.