Skip to content

Use .gitignore by default when loading modules #6627

@helderco

Description

@helderco

Motivation

I have to constantly add "exclude": ["sdk", ".venv"] to dagger.json after dagger init.

I don't expect these files to be uploaded. They're not completely replaced in codegen. During local dev, some files can be created in there and they will stay after codegen in the container. It affects the Source dir cache and slows down module loading.

Solution

The engine already loads dagger.json first. Load .gitignore too. Prepend the .gitignore patterns to the exclude patterns from dagger.json when collecting the patterns for loading the module’s files.

As an escape hatch, if the user needs to include something in .gitignore they can add the same pattern manually to include in dagger.json.

Rationale

This seems like the easiest solution, with less work for the user but keeping control.

Doesn’t require extra work. Most modules in the Daggerverse have the automatically generated .gitignore but no patterns in "exclude". By using .gitignore, those modules would benefit automatically. Of course, this is only necessary when dagger developing modules locally.

When a module is loaded via a git reference, those patterns are already applied because the git clone won’t have those files. So using .gitignore is actually more consistent because it avoids differences in dirty working copies.

It’s still possible to have dirty woking copies because global ignores won’t be picked up, but rather than adding some of those to exclude, users might as well just add them to .gitignore which also helps other users contributing to a module that don’t have the same global ignores.

It’s also possible for files in a module to be ignored by some other .gitignore up the file tree until the git repo root, but we could automatically find those and add their patterns, prefixed with their file path relative to the context directory, to the module’s excludes.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions