Skip to content

Commit

Permalink
improvement(core): don't respect .gitignore files by default
Browse files Browse the repository at this point in the history
The previous default behavior has been known to cause confusion, and
sometimes makes it difficult to correctly control which files should
be used for build contexts. We now default to only respect
`.gardenignore` files.

You can override the default behavior by explicitly setting the
`dotIgnoreFiles` field in your project configuration.

The `garden create project` command now also copies a .gitignore file
next to the project config file, if one is found, and instructs the
user accordingly.

I also added a bunch of .gardenignore files (and sometimes missing
.gitignore files) to our examples.

BREAKING CHANGE:

Garden no longer respects `.gitignore` files by default now. If you'd
like to retain the previous default behavior, you can explicitly set
`dotIgnoreFiles: [.gitignore, .gardenignore]` in your project configs.
If you already have `dotIgnoreFiles` set in your config, no change is
necessary.
  • Loading branch information
edvald committed Jun 24, 2020
1 parent f6a6484 commit c7ef453
Show file tree
Hide file tree
Showing 66 changed files with 535 additions and 26 deletions.
12 changes: 8 additions & 4 deletions docs/guides/configuration-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,11 @@ Note that the module `include` and `exclude` fields have no effect on which path

#### .ignore files

By default, Garden respects `.gitignore` and `.gardenignore` files and excludes any patterns matched in those files.
{% hint style="warning" %}
Prior to Garden 0.12.0, `.gitignore` files were also respected by default. The default is now to only respect `.gardenignore` files. See below how you can revert to the previous behavior.
{% endhint %}

By default, Garden respects `.gardenignore` files and excludes any patterns matched in those files. You can place the ignore files anywhere in your repository, much like `.gitignore` files, and they will follow the same semantics.

You can use those to exclude files and directories across the project, _both from being scanned for Garden modules and when selecting source files for individual module_. For example, you might put this `.gardenignore` file in your project root directory:

Expand All @@ -391,16 +395,16 @@ public
*.log
```

This would cause Garden to ignore `node_modules` and `public` directories across your project/repo, and all `.log` files. You can place the ignore files anywhere in your repository, much like `.gitignore` files, and they will follow the same semantics.
This would cause Garden to ignore `node_modules` and `public` directories across your project/repo, and all `.log` files.

Note that _these take precedence over both `modules.include` fields in your project config, and `include` fields in your module configs_. If a path is matched by one of the ignore files, the path will not be included in your project or modules.

You can override which filenames to use as ".ignore" files using the `dotIgnoreFiles` field in your project configuration. For example, you might choose to only use `.gardenignore` files and not exclude paths based on your `.gitignore` files:
You can override which filenames to use as ".ignore" files using the `dotIgnoreFiles` field in your project configuration. For example, you might choose to also respect `.gitignore` files (this was the default behavior prior to Garden 0.12.0):

```yaml
kind: Project
name: my-project
dotIgnoreFiles: [.gardenignore]
dotIgnoreFiles: [.gardenignore, .gitignore]
```

#### Git submodules
Expand Down
16 changes: 8 additions & 8 deletions docs/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ providers:
defaultEnvironment: ''

# Specify a list of filenames that should be used as ".ignore" files across the project, using the same syntax and
# semantics as `.gitignore` files. By default, patterns matched in `.gitignore` and `.gardenignore` files, found
# anywhere in the project, are ignored when scanning for modules and module sources.
# semantics as `.gitignore` files. By default, patterns matched in `.gardenignore` files, found anywhere in the
# project, are ignored when scanning for modules and module sources (Note: prior to version 0.12.0, `.gitignore` files
# were also used by default).
# Note that these take precedence over the project `module.include` field, and module `include` fields, so any paths
# matched by the .ignore files will be ignored even if they are explicitly specified in those fields.
# See the [Configuration Files
# guide](https://docs.garden.io/guides/configuration-files#including-excluding-files-and-directories) for details.
dotIgnoreFiles:
- .gitignore
- .gardenignore

# Control where to scan for modules in the project.
Expand Down Expand Up @@ -429,20 +429,20 @@ defaultEnvironment: "dev"

### `dotIgnoreFiles[]`

Specify a list of filenames that should be used as ".ignore" files across the project, using the same syntax and semantics as `.gitignore` files. By default, patterns matched in `.gitignore` and `.gardenignore` files, found anywhere in the project, are ignored when scanning for modules and module sources.
Specify a list of filenames that should be used as ".ignore" files across the project, using the same syntax and semantics as `.gitignore` files. By default, patterns matched in `.gardenignore` files, found anywhere in the project, are ignored when scanning for modules and module sources (Note: prior to version 0.12.0, `.gitignore` files were also used by default).
Note that these take precedence over the project `module.include` field, and module `include` fields, so any paths matched by the .ignore files will be ignored even if they are explicitly specified in those fields.
See the [Configuration Files guide](https://docs.garden.io/guides/configuration-files#including-excluding-files-and-directories) for details.

| Type | Default | Required |
| ------------------ | -------------------------------- | -------- |
| `array[posixPath]` | `[".gitignore",".gardenignore"]` | No |
| Type | Default | Required |
| ------------------ | ------------------- | -------- |
| `array[posixPath]` | `[".gardenignore"]` | No |

Example:

```yaml
dotIgnoreFiles:
- .gardenignore
- .customignore
- .gitignore
```

### `modules`
Expand Down
27 changes: 27 additions & 0 deletions examples/ambassador/go-service/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

.vscode/settings.json
webserver/*server*
15 changes: 15 additions & 0 deletions examples/ambassador/node-service/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
27 changes: 27 additions & 0 deletions examples/base-image/backend/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

.vscode/settings.json
webserver/*server*
27 changes: 27 additions & 0 deletions examples/build-dependencies/backend/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

.vscode/settings.json
webserver/*server*
1 change: 1 addition & 0 deletions examples/build-dependencies/frontend/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
27 changes: 27 additions & 0 deletions examples/demo-project-start/backend/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

.vscode/settings.json
webserver/*server*
1 change: 1 addition & 0 deletions examples/demo-project-start/frontend/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions examples/demo-project-start/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
27 changes: 27 additions & 0 deletions examples/demo-project/backend/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

.vscode/settings.json
webserver/*server*
1 change: 1 addition & 0 deletions examples/demo-project/frontend/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
27 changes: 27 additions & 0 deletions examples/deployment-strategies/backend/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

.vscode/settings.json
webserver/*server*
1 change: 1 addition & 0 deletions examples/deployment-strategies/frontend/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions examples/deployment-strategies/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
27 changes: 27 additions & 0 deletions examples/disabled-configs/backend/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

.vscode/settings.json
webserver/*server*
1 change: 1 addition & 0 deletions examples/disabled-configs/frontend/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions examples/disabled-configs/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
8 changes: 8 additions & 0 deletions examples/gatsby-hot-reload/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Project dependencies
.cache
node_modules
yarn-error.log

# Build directory
/public
.DS_Store
27 changes: 27 additions & 0 deletions examples/hadolint/backend/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

.vscode/settings.json
webserver/*server*
1 change: 1 addition & 0 deletions examples/hadolint/frontend/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions examples/hadolint/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions examples/hot-reload/node-service/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions examples/hot-reload/node-service/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
27 changes: 27 additions & 0 deletions examples/kaniko/backend/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

.vscode/settings.json
webserver/*server*
1 change: 1 addition & 0 deletions examples/kaniko/frontend/.gardenignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions examples/kaniko/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
Loading

0 comments on commit c7ef453

Please sign in to comment.