Skip to content

Various gitignore fixes - #11017

Merged
jedevc merged 6 commits into
dagger:mainfrom
jedevc:gitignore-fixes
Sep 16, 2025
Merged

jedevc merged 6 commits into
dagger:mainfrom
jedevc:gitignore-fixes

Conversation

@jedevc

@jedevc jedevc commented Sep 9, 2025 •

Copy link
Copy Markdown
Contributor

Fixes #10994 and other related issues.

See individual commits for detailed explanation.

@jedevc
jedevc force-pushed the gitignore-fixes branch 4 times, most recently from c836e91 to f282fbd Compare September 10, 2025 10:59
Comment thread core/schema/host.go
dagql.Arg("include").Doc(`Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).`),
dagql.Arg("noCache").Doc(`If true, the directory will always be reloaded from the host.`),
dagql.Arg("noGitAutoIgnore").Doc(`Don't apply .gitignore filter rules inside the directory`),
dagql.Arg("gitignore").Doc(`Apply .gitignore filter rules inside the directory`),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The big change here is this.

I want to make this opt-in - we made a breaking change accidentally, and I think it's worth backing out of that. Since this API cannot be called by modules, it's outside module-compat so we should be fine for that.

This makes more sense with the approach we're going for now; we only need to add it for module loading, instead of needing to opt out for flag loading, and for context directories, and tests, etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@shykes can I get a check here?

Since we all agreed on the API before, wanna make sure I get everyone involved with that original discussion on board here.

@shykes shykes Sep 15, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes I'm on board. Technically this should be gitAutoIgnore for consistency with past bikeshedding, but I'm going to assume this is your personal preference, and drop that particular nit 😁

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup, I don't think we need the auto in there - it's not automatic anymore, you need to enable it, so I think we should remove that, and just keep it to gitignore.

@jedevc
jedevc force-pushed the gitignore-fixes branch 2 times, most recently from 865c318 to fe517f1 Compare September 10, 2025 14:45
@jedevc
jedevc marked this pull request as ready for review September 10, 2025 15:03
@jedevc
jedevc requested review from a team as code owners September 10, 2025 15:03
@jedevc
jedevc requested review from TomChv and shykes September 10, 2025 15:04
@jedevc
jedevc force-pushed the gitignore-fixes branch 7 times, most recently from 8533db7 to c539c2d Compare September 12, 2025 10:16
@jedevc jedevc added this to the v0.18.18 milestone Sep 15, 2025

@sipsma sipsma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM one quick nit

Comment thread engine/sources/local/copy/copy.go Resolved
Signed-off-by: Justin Chadwell <[email protected]>
This was a weird one - if you forcefully excluded loading gitignore
while attempting to apply the gitignore, you could get inconsistent
results.

Assuming strictly serial uploads this was fine, but in parallel, we're
very careful to ensure that the shared file store is in a consistent
state.

For example, suppose:
- From /src, we upload a large a.txt (using include=a.txt)
- From /src in parallel, we upload a .gitignore containing a.txt (using
  exclude=.gitignore, and applying gitignore)
    - The expected outcome is to not upload a.txt
- But, because a.txt is in the local copy and the gitignore is *not* (we
  skipped uploading it), then we incorrectly will copy a.txt to our
  snapshot.

The *core* problem here is that we are effectively applying
includes+excludes and gitignores *twice*. First when uploading, and
second when we copy to our snapshot.

We can fix this! Instead of applying the patterns again on the second
copy, we know *exactly* what files need to be copied (based on the
transfer results), so can just include those.

Signed-off-by: Justin Chadwell <[email protected]>
Update syncParentDirs to always sync over gitignores. This ensures that
the gitignore patterns between local/remote *always* match.

This wasn't previously true, and so could have potentially meant that we
were removing files that were still being used. Imagine the scenario:
- We upload a large a.txt, excluded by gitignore, but gitignore not applied
- We upload something else, and apply gitignore (but avoid transferring
  the gitignore, by excluding the gitignore file in a pattern)
    - This will remove a.txt, because now local has no idea that it
      should be excluded.
- If we upload the same a.txt again, we'll have to do it again from
  scratch.

This is all weird, so instead of this, we'll just first sync *all* the
gitignores, so that the context perfectly matches. This actually
resolves the same problem as the prior commit - but also resolves the
above issue. Technically, this would work by itself, but the additional
copy is still confusing and should still be removed.

Signed-off-by: Justin Chadwell <[email protected]>
And apply it to module loading.

Signed-off-by: Justin Chadwell <[email protected]>
It turns out to be much *cheaper* to apply gitignores after
include/exclude.

e.g. we might come to exclude a huge directory - in that case, it's not
worth looking for gitignore patterns in there. So we can filter that out
before.

But we still use the original filesystem for matching! That way, we
can't accidentally exclude the gitignore.

Signed-off-by: Justin Chadwell <[email protected]>
@jedevc
jedevc merged commit 02a8a97 into dagger:main Sep 16, 2025
@jedevc
jedevc deleted the gitignore-fixes branch September 16, 2025 10:49
michaelkirk added a commit to headwaymaps/headway that referenced this pull request Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐞 defaultPath cannot use files ignored by .gitignore on dagger call

4 participants