Skip to content

Add .gitattributes file #29277

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

Closed
wants to merge 1 commit into from
Closed

Add .gitattributes file #29277

wants to merge 1 commit into from

Conversation

seriquynh
Copy link
Contributor

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

Currently, when using a Symfony component as a dependency, Composer will download all the files from the source repository. In fact, there are a lot of unnecessary files. For example, Our PHP projects don't require .gitignore, CHANGELOG.md, .github,.. to run. Especially, we don't need the Tests directory, do we?

/path/to/project/vendor/symfony/http-foundation/Tests are no-meaning.

In this pull request, I just add a .gitattributes file to ignore some files when exporting.

@javiereguiluz
Copy link
Member

@XuanQuynh thanks for your pull request! It's great to see contributions from the Vietnam Symfony community!

Regarding your proposal, I'm afraid it has been proposed other times in the past (see https://github.com/symfony/symfony/pulls?q=is%3Apr+gitattributes+is%3Aclosed) and it was always rejected for some reasons. I'd love to see this merged, but let's wait and see the opinions of other "Symfony Core Team" members. Maybe they have changed their opinions about this and now they agree. Let's wait and see. Thanks!

@nicolas-grekas
Copy link
Member

The reasoning is described in what Javier linked to: tests should come with the source because they're useful to help discover how some code can be used. For packages that have decided to go down this route, I've been missing this possiblity many times. If you don't want these files, you can remove them, or use a script to do so.

👎

@lyrixx lyrixx closed this Nov 22, 2018
@lyrixx lyrixx reopened this Nov 22, 2018
@lyrixx
Copy link
Member

lyrixx commented Nov 22, 2018

I'm still 👎 with this.

@fabpot fabpot closed this Nov 22, 2018
@seriquynh seriquynh deleted the add_gitattributes_file branch November 22, 2018 14:18
fabpot added a commit that referenced this pull request Sep 16, 2019
…dist" (Nyholm)

This PR was merged into the 4.4 branch.

Discussion
----------

Adding .gitattributes to remove Tests directory from "dist"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no?
| Tickets       |
| License       | MIT
| Doc PR        |

This is a controversial topic that have been mentioned before. We recently had some discussions on Slack about it and the community not in an agreement. This was asked back in 2014 already.

Im making this PR again, because I think this will help more people than it hurts to keep the tests in the "dist" version.

### Reasons for keeping the tests with the source

* You can look at the tests to understand how the code works
* It is convenient

In the past there were an argument of people might depend on Symfony's classes in Tests. That is no longer the case since we moved reusable classes from Tests to Test.

### Reasons for removing them (merging this PR)

* There should be difference between `composer update --prefer-source` and `composer update --prefer-dist`
* Smaller packages when deploying with Docker or on Serverless.
* Static analysis tools will not complain on PHP syntax errors in our tests ([example](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/xml_with_wrong_ext.php))

## How to decide?

Merging this PR or not is tricky because no side has a solid technical argument. It is basically just personal preference. Please give this PR a 👍 or 👎 if you want to give your opinion.

## Other PRs and issues related to this:

Add .gitattributes file (#29277)
Added .gitattributes files to root and all components (#26472)
Exclude non-essential files from Composer package (#25414)
[HttpFoundation] optimize files for distribution (#24427)
Add .gitattributes files (#23926)
[Suggestion] Adding .gitattributes to ignore unnecessary folders and files for production env (#20057)
Add lightweight and root only .gitattributes (#18004)
Add .gitattributes to exclude tests from ZIPs (#17995)
[RFC] Move tests out of the source and source out of the tests (#17749)
Removal of development & testing files using .gitattributes (#16174)
Please add .gitattributes files and fix line endings (#13521)
making use of .gitattributes (#11810)

## Workarounds

There are workarounds for both sides. Example:

### Workaround if merged

* `composer update --prefer-source`

### Workaround if closed

* `find vendor/symfony -name "Tests" -type d -exec rm -r "{}" \;`
* editorconfig/editorconfig#228
* https://github.com/dg/composer-cleaner

Commits
-------

ac7dc24 Adding .gitattributes to remove Tests directory from "dist"
symfony-splitter pushed a commit to symfony/mailer that referenced this pull request Sep 16, 2019
…dist" (Nyholm)

This PR was merged into the 4.4 branch.

Discussion
----------

Adding .gitattributes to remove Tests directory from "dist"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no?
| Tickets       |
| License       | MIT
| Doc PR        |

This is a controversial topic that have been mentioned before. We recently had some discussions on Slack about it and the community not in an agreement. This was asked back in 2014 already.

Im making this PR again, because I think this will help more people than it hurts to keep the tests in the "dist" version.

### Reasons for keeping the tests with the source

* You can look at the tests to understand how the code works
* It is convenient

In the past there were an argument of people might depend on Symfony's classes in Tests. That is no longer the case since we moved reusable classes from Tests to Test.

### Reasons for removing them (merging this PR)

* There should be difference between `composer update --prefer-source` and `composer update --prefer-dist`
* Smaller packages when deploying with Docker or on Serverless.
* Static analysis tools will not complain on PHP syntax errors in our tests ([example](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/xml_with_wrong_ext.php))

## How to decide?

Merging this PR or not is tricky because no side has a solid technical argument. It is basically just personal preference. Please give this PR a 👍 or 👎 if you want to give your opinion.

## Other PRs and issues related to this:

Add .gitattributes file (symfony/symfony#29277)
Added .gitattributes files to root and all components (symfony/symfony#26472)
Exclude non-essential files from Composer package (symfony/symfony#25414)
[HttpFoundation] optimize files for distribution (symfony/symfony#24427)
Add .gitattributes files (symfony/symfony#23926)
[Suggestion] Adding .gitattributes to ignore unnecessary folders and files for production env (symfony/symfony#20057)
Add lightweight and root only .gitattributes (symfony/symfony#18004)
Add .gitattributes to exclude tests from ZIPs (symfony/symfony#17995)
[RFC] Move tests out of the source and source out of the tests (symfony/symfony#17749)
Removal of development & testing files using .gitattributes (symfony/symfony#16174)
Please add .gitattributes files and fix line endings (symfony/symfony#13521)
making use of .gitattributes (symfony/symfony#11810)

## Workarounds

There are workarounds for both sides. Example:

### Workaround if merged

* `composer update --prefer-source`

### Workaround if closed

* `find vendor/symfony -name "Tests" -type d -exec rm -r "{}" \;`
* editorconfig/editorconfig#228
* https://github.com/dg/composer-cleaner

Commits
-------

ac7dc24bcb Adding .gitattributes to remove Tests directory from "dist"
symfony-splitter pushed a commit to symfony/web-profiler-bundle that referenced this pull request Sep 16, 2019
…dist" (Nyholm)

This PR was merged into the 4.4 branch.

Discussion
----------

Adding .gitattributes to remove Tests directory from "dist"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no?
| Tickets       |
| License       | MIT
| Doc PR        |

This is a controversial topic that have been mentioned before. We recently had some discussions on Slack about it and the community not in an agreement. This was asked back in 2014 already.

Im making this PR again, because I think this will help more people than it hurts to keep the tests in the "dist" version.

### Reasons for keeping the tests with the source

* You can look at the tests to understand how the code works
* It is convenient

In the past there were an argument of people might depend on Symfony's classes in Tests. That is no longer the case since we moved reusable classes from Tests to Test.

### Reasons for removing them (merging this PR)

* There should be difference between `composer update --prefer-source` and `composer update --prefer-dist`
* Smaller packages when deploying with Docker or on Serverless.
* Static analysis tools will not complain on PHP syntax errors in our tests ([example](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/xml_with_wrong_ext.php))

## How to decide?

Merging this PR or not is tricky because no side has a solid technical argument. It is basically just personal preference. Please give this PR a 👍 or 👎 if you want to give your opinion.

## Other PRs and issues related to this:

Add .gitattributes file (symfony/symfony#29277)
Added .gitattributes files to root and all components (symfony/symfony#26472)
Exclude non-essential files from Composer package (symfony/symfony#25414)
[HttpFoundation] optimize files for distribution (symfony/symfony#24427)
Add .gitattributes files (symfony/symfony#23926)
[Suggestion] Adding .gitattributes to ignore unnecessary folders and files for production env (symfony/symfony#20057)
Add lightweight and root only .gitattributes (symfony/symfony#18004)
Add .gitattributes to exclude tests from ZIPs (symfony/symfony#17995)
[RFC] Move tests out of the source and source out of the tests (symfony/symfony#17749)
Removal of development & testing files using .gitattributes (symfony/symfony#16174)
Please add .gitattributes files and fix line endings (symfony/symfony#13521)
making use of .gitattributes (symfony/symfony#11810)

## Workarounds

There are workarounds for both sides. Example:

### Workaround if merged

* `composer update --prefer-source`

### Workaround if closed

* `find vendor/symfony -name "Tests" -type d -exec rm -r "{}" \;`
* editorconfig/editorconfig#228
* https://github.com/dg/composer-cleaner

Commits
-------

ac7dc24bcb Adding .gitattributes to remove Tests directory from "dist"
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull request Sep 16, 2019
…dist" (Nyholm)

This PR was merged into the 4.4 branch.

Discussion
----------

Adding .gitattributes to remove Tests directory from "dist"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no?
| Tickets       |
| License       | MIT
| Doc PR        |

This is a controversial topic that have been mentioned before. We recently had some discussions on Slack about it and the community not in an agreement. This was asked back in 2014 already.

Im making this PR again, because I think this will help more people than it hurts to keep the tests in the "dist" version.

### Reasons for keeping the tests with the source

* You can look at the tests to understand how the code works
* It is convenient

In the past there were an argument of people might depend on Symfony's classes in Tests. That is no longer the case since we moved reusable classes from Tests to Test.

### Reasons for removing them (merging this PR)

* There should be difference between `composer update --prefer-source` and `composer update --prefer-dist`
* Smaller packages when deploying with Docker or on Serverless.
* Static analysis tools will not complain on PHP syntax errors in our tests ([example](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/xml_with_wrong_ext.php))

## How to decide?

Merging this PR or not is tricky because no side has a solid technical argument. It is basically just personal preference. Please give this PR a 👍 or 👎 if you want to give your opinion.

## Other PRs and issues related to this:

Add .gitattributes file (symfony/symfony#29277)
Added .gitattributes files to root and all components (symfony/symfony#26472)
Exclude non-essential files from Composer package (symfony/symfony#25414)
[HttpFoundation] optimize files for distribution (symfony/symfony#24427)
Add .gitattributes files (symfony/symfony#23926)
[Suggestion] Adding .gitattributes to ignore unnecessary folders and files for production env (symfony/symfony#20057)
Add lightweight and root only .gitattributes (symfony/symfony#18004)
Add .gitattributes to exclude tests from ZIPs (symfony/symfony#17995)
[RFC] Move tests out of the source and source out of the tests (symfony/symfony#17749)
Removal of development & testing files using .gitattributes (symfony/symfony#16174)
Please add .gitattributes files and fix line endings (symfony/symfony#13521)
making use of .gitattributes (symfony/symfony#11810)

## Workarounds

There are workarounds for both sides. Example:

### Workaround if merged

* `composer update --prefer-source`

### Workaround if closed

* `find vendor/symfony -name "Tests" -type d -exec rm -r "{}" \;`
* editorconfig/editorconfig#228
* https://github.com/dg/composer-cleaner

Commits
-------

ac7dc24bcb Adding .gitattributes to remove Tests directory from "dist"
symfony-splitter pushed a commit to symfony/cache that referenced this pull request Sep 16, 2019
…dist" (Nyholm)

This PR was merged into the 4.4 branch.

Discussion
----------

Adding .gitattributes to remove Tests directory from "dist"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no?
| Tickets       |
| License       | MIT
| Doc PR        |

This is a controversial topic that have been mentioned before. We recently had some discussions on Slack about it and the community not in an agreement. This was asked back in 2014 already.

Im making this PR again, because I think this will help more people than it hurts to keep the tests in the "dist" version.

### Reasons for keeping the tests with the source

* You can look at the tests to understand how the code works
* It is convenient

In the past there were an argument of people might depend on Symfony's classes in Tests. That is no longer the case since we moved reusable classes from Tests to Test.

### Reasons for removing them (merging this PR)

* There should be difference between `composer update --prefer-source` and `composer update --prefer-dist`
* Smaller packages when deploying with Docker or on Serverless.
* Static analysis tools will not complain on PHP syntax errors in our tests ([example](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/xml_with_wrong_ext.php))

## How to decide?

Merging this PR or not is tricky because no side has a solid technical argument. It is basically just personal preference. Please give this PR a 👍 or 👎 if you want to give your opinion.

## Other PRs and issues related to this:

Add .gitattributes file (symfony/symfony#29277)
Added .gitattributes files to root and all components (symfony/symfony#26472)
Exclude non-essential files from Composer package (symfony/symfony#25414)
[HttpFoundation] optimize files for distribution (symfony/symfony#24427)
Add .gitattributes files (symfony/symfony#23926)
[Suggestion] Adding .gitattributes to ignore unnecessary folders and files for production env (symfony/symfony#20057)
Add lightweight and root only .gitattributes (symfony/symfony#18004)
Add .gitattributes to exclude tests from ZIPs (symfony/symfony#17995)
[RFC] Move tests out of the source and source out of the tests (symfony/symfony#17749)
Removal of development & testing files using .gitattributes (symfony/symfony#16174)
Please add .gitattributes files and fix line endings (symfony/symfony#13521)
making use of .gitattributes (symfony/symfony#11810)

## Workarounds

There are workarounds for both sides. Example:

### Workaround if merged

* `composer update --prefer-source`

### Workaround if closed

* `find vendor/symfony -name "Tests" -type d -exec rm -r "{}" \;`
* editorconfig/editorconfig#228
* https://github.com/dg/composer-cleaner

Commits
-------

ac7dc24bcb Adding .gitattributes to remove Tests directory from "dist"
symfony-splitter pushed a commit to symfony/yaml that referenced this pull request Sep 16, 2019
…dist" (Nyholm)

This PR was merged into the 4.4 branch.

Discussion
----------

Adding .gitattributes to remove Tests directory from "dist"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no?
| Tickets       |
| License       | MIT
| Doc PR        |

This is a controversial topic that have been mentioned before. We recently had some discussions on Slack about it and the community not in an agreement. This was asked back in 2014 already.

Im making this PR again, because I think this will help more people than it hurts to keep the tests in the "dist" version.

### Reasons for keeping the tests with the source

* You can look at the tests to understand how the code works
* It is convenient

In the past there were an argument of people might depend on Symfony's classes in Tests. That is no longer the case since we moved reusable classes from Tests to Test.

### Reasons for removing them (merging this PR)

* There should be difference between `composer update --prefer-source` and `composer update --prefer-dist`
* Smaller packages when deploying with Docker or on Serverless.
* Static analysis tools will not complain on PHP syntax errors in our tests ([example](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/xml_with_wrong_ext.php))

## How to decide?

Merging this PR or not is tricky because no side has a solid technical argument. It is basically just personal preference. Please give this PR a 👍 or 👎 if you want to give your opinion.

## Other PRs and issues related to this:

Add .gitattributes file (symfony/symfony#29277)
Added .gitattributes files to root and all components (symfony/symfony#26472)
Exclude non-essential files from Composer package (symfony/symfony#25414)
[HttpFoundation] optimize files for distribution (symfony/symfony#24427)
Add .gitattributes files (symfony/symfony#23926)
[Suggestion] Adding .gitattributes to ignore unnecessary folders and files for production env (symfony/symfony#20057)
Add lightweight and root only .gitattributes (symfony/symfony#18004)
Add .gitattributes to exclude tests from ZIPs (symfony/symfony#17995)
[RFC] Move tests out of the source and source out of the tests (symfony/symfony#17749)
Removal of development & testing files using .gitattributes (symfony/symfony#16174)
Please add .gitattributes files and fix line endings (symfony/symfony#13521)
making use of .gitattributes (symfony/symfony#11810)

## Workarounds

There are workarounds for both sides. Example:

### Workaround if merged

* `composer update --prefer-source`

### Workaround if closed

* `find vendor/symfony -name "Tests" -type d -exec rm -r "{}" \;`
* editorconfig/editorconfig#228
* https://github.com/dg/composer-cleaner

Commits
-------

ac7dc24bcb Adding .gitattributes to remove Tests directory from "dist"
symfony-splitter pushed a commit to symfony/mailer that referenced this pull request Sep 28, 2021
…dist" (Nyholm)

This PR was merged into the 4.4 branch.

Discussion
----------

Adding .gitattributes to remove Tests directory from "dist"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no?
| Tickets       |
| License       | MIT
| Doc PR        |

This is a controversial topic that have been mentioned before. We recently had some discussions on Slack about it and the community not in an agreement. This was asked back in 2014 already.

Im making this PR again, because I think this will help more people than it hurts to keep the tests in the "dist" version.

### Reasons for keeping the tests with the source

* You can look at the tests to understand how the code works
* It is convenient

In the past there were an argument of people might depend on Symfony's classes in Tests. That is no longer the case since we moved reusable classes from Tests to Test.

### Reasons for removing them (merging this PR)

* There should be difference between `composer update --prefer-source` and `composer update --prefer-dist`
* Smaller packages when deploying with Docker or on Serverless.
* Static analysis tools will not complain on PHP syntax errors in our tests ([example](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/xml_with_wrong_ext.php))

## How to decide?

Merging this PR or not is tricky because no side has a solid technical argument. It is basically just personal preference. Please give this PR a 👍 or 👎 if you want to give your opinion.

## Other PRs and issues related to this:

Add .gitattributes file (symfony/symfony#29277)
Added .gitattributes files to root and all components (symfony/symfony#26472)
Exclude non-essential files from Composer package (symfony/symfony#25414)
[HttpFoundation] optimize files for distribution (symfony/symfony#24427)
Add .gitattributes files (symfony/symfony#23926)
[Suggestion] Adding .gitattributes to ignore unnecessary folders and files for production env (symfony/symfony#20057)
Add lightweight and root only .gitattributes (symfony/symfony#18004)
Add .gitattributes to exclude tests from ZIPs (symfony/symfony#17995)
[RFC] Move tests out of the source and source out of the tests (symfony/symfony#17749)
Removal of development & testing files using .gitattributes (symfony/symfony#16174)
Please add .gitattributes files and fix line endings (symfony/symfony#13521)
making use of .gitattributes (symfony/symfony#11810)

## Workarounds

There are workarounds for both sides. Example:

### Workaround if merged

* `composer update --prefer-source`

### Workaround if closed

* `find vendor/symfony -name "Tests" -type d -exec rm -r "{}" \;`
* editorconfig/editorconfig#228
* https://github.com/dg/composer-cleaner

Commits
-------

ac7dc24bcb Adding .gitattributes to remove Tests directory from "dist"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants