pub icon indicating copy to clipboard operation
pub copied to clipboard

.gitignore validator triggers even when I have a different .pubignore in mono_repos

Open jakemac53 opened this issue 4 years ago • 7 comments

Environment

  • pub version or flutter pub version: 2.15.0-233.0.dev

Problem

I was trying to migrate the test package to use a .pubignore file to work around the issue where it has a required file that is covered by a .gitignore, https://github.com/dart-lang/test/pull/1623/commits/5c55cf5f2524a11f60292a2bdce37d2b12386381.

When I run pub lish --dry-run with that file I still got the validator warning about the .gitignore lines:

Package validation found the following potential issues:
* 1 checked in file is ignored by a `.gitignore`.
  Previous versions of Pub would include those in the published package.
  
  Consider adjusting your `.gitignore` files to not ignore those files, and if you do not wish to
  publish these files use `.pubignore`. See also dart.dev/go/pubignore
  
  Files that are checked in while gitignored:
  
  lib/src/runner/browser/static/host.dart.js

Expected behavior

I expected to not get a validator warning (it should use the .pubignore not the .gitignore).

So I didn't have confidence that it was actually working and just removed the lines from the .gitignore.

jakemac53 avatar Oct 25 '21 14:10 jakemac53

Same problem here, even if file is in pubignore we still have the warning

MobiliteDev avatar Nov 29 '21 10:11 MobiliteDev

We have a similar issue. We have added two submodules to our repo, and even though we have added the paths to the submodules to the .pubignore file, we are still getting a warning similar to the one mentioned in the first post.

graduad avatar Jan 05 '23 10:01 graduad

Sorry for never returning to this issue.

I can still reproduce the reported behavior.

It seems to me that lib/src/runner/browser/static/host.dart.js indeed is matched by the .gitignore file, and is also checked in. Is it intended to be part of the publication? In that case I would add an exception to the .gitignore file:

...
*.dart.js
!pkgs/test/lib/src/runner/browser/static/host.dart.js # <- this should not be gitignored
...

Then I think you can remove the .pubignore file.

sigurdm avatar Jan 05 '24 12:01 sigurdm

I think this is working as intended

@jakemac53 can you confirm?

sigurdm avatar Jan 05 '24 12:01 sigurdm

It does indeed work to explicitly allow the checked in files in the .gitignore.

jakemac53 avatar Jan 05 '24 17:01 jakemac53

However reading back over the original issue, it sounds like the problem is that the .gitignore is read even when a .pubignore is present, which is not working as documented?

jakemac53 avatar Jan 05 '24 17:01 jakemac53

Yeah - we should probably not warn about about "checked-in but gitignored" files if they are anyway covered by a pubignore...

sigurdm avatar Jan 08 '24 08:01 sigurdm