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

Introduce .pubignore #2787

Merged
merged 55 commits into from
Mar 12, 2021
Merged

Introduce .pubignore #2787

merged 55 commits into from
Mar 12, 2021

Conversation

sigurdm
Copy link
Contributor

@sigurdm sigurdm commented Dec 4, 2020

Implements .gitignore style files called .pubignore.

Files ignored by a .pubignore will not be published (no matter if they are checked in to git).

A .pubignore in a folder will override a .gitignore if both are present in the same folder.

pub will now no longer call out to git to have .gitignore files interpreted.
This results in some subtle changes in the package listings:

  • .gitignore files are taken into account even if the root is not a git directory.
  • global gitignore files are not taken into account.
  • files that are ignored by a .gitignore but checked into git, would be listed by pub previously, but now they are ignored by pub.
    • Added a publish-time validator to warn against this case (it is most likely a mistake when this happens, and can always be avoided by writing more .gitignore rules).

Changed package.listFiles to always take ignore files into account - no usecases warranted the difference.

Most implementation of ignore.dart by jonasfj@

fixes: #2222
fixes: #2786
fixes: #2566

@google-cla google-cla bot added the cla: yes label Dec 4, 2020
@sigurdm sigurdm changed the title Introduce ignore Introduce pubignore Dec 7, 2020
@jonasfj
Copy link
Member

jonasfj commented Dec 8, 2020

We had some discussions, consider the following options:
(A) .pubignore in any folder (same syntax as .gitignore).
(B) files: ['glob/pattern/for/**/file.dart', ...] in pubspec.yaml (if present, only files matching a pattern is included)
(C) include: ['glob/pattern/for/**/file.dart', ...], exclude: ['glob/pattern/for/**/file.dart', ...] in pubspec.yaml
(D) exclude: ['glob/pattern/for/**/file.dart', ...] in pubspec.yaml

I'm personally attracted to (A) because:

  • It's the same syntax as .gitignore,
  • Any glob-patterns we invent won't be as expressive as .gitignore (e.g. / has special meaning in the start of a pattern),
  • The .pubignore file itself should not be included when publishing the package:
    • If user is ignoring private files they don't want to share, they might not want to share the file-patterns they are ignoring,
    • This is information that isn't needed in the package,
    • Options (B), (C), (D) needlessly increases the pubspec, which increases the size of all responses from the list-versions API.
  • Like a .gitignore file, you can have a multiple .pubignore files, you don't need to put in the root directory. If you are generating some temporary files, you can simply generate a .pubignore file in said directory too to avoid publishing any of them.

@sigurdm, @isoos thoughts?

@sigurdm
Copy link
Contributor Author

sigurdm commented Dec 21, 2020

Yeah - the main complaint about .pubignore files is that we now have even more ("hidden") files floating around.

But for most users pubignore will not be needed.

@sigurdm sigurdm changed the title Introduce pubignore Introduce .pubignore Jan 12, 2021
@sigurdm sigurdm requested a review from jonasfj March 1, 2021 15:26
sigurdm and others added 2 commits March 11, 2021 13:40
@sigurdm sigurdm requested a review from jonasfj March 11, 2021 13:17
Copy link
Member

@jonasfj jonasfj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's pull this into dart-sdk ASAP, so we can get some testing in dev releases..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants