From dc1da89efab8a6988e1ab4b770c6e444145b6ec1 Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 21 Nov 2022 20:43:59 +0100 Subject: [PATCH 1/2] Make include_file overrule include_ext Essentially, a file can now be in `include_file` without having its extension in `include_ext`, which I generally think is the expected behaviour because explicit filenames are more specific than extensions. Fixes: https://github.com/cosmtrek/air/issues/350 --- runner/engine.go | 6 +++--- runner/engine_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runner/engine.go b/runner/engine.go index 5f004d2a..d3421c16 100644 --- a/runner/engine.go +++ b/runner/engine.go @@ -186,7 +186,7 @@ func (e *Engine) cacheFileChecksums(root string) error { } } - if e.isExcludeFile(path) || !e.isIncludeExt(path) { + if e.isExcludeFile(path) || !e.isIncludeExt(ev.Name) && !e.checkIncludeFile(path) { e.watcherDebug("!exclude checksum %s", e.config.rel(path)) return nil } @@ -251,7 +251,7 @@ func (e *Engine) watchPath(path string) error { if excludeRegex { break } - if !e.isIncludeExt(ev.Name) { + if !e.isIncludeExt(ev.Name) && !e.checkIncludeFile(path) { break } e.watcherDebug("%s has changed", e.config.rel(ev.Name)) @@ -317,7 +317,7 @@ func (e *Engine) start() { e.mainDebug("exit in start") return case filename = <-e.eventCh: - if !e.isIncludeExt(filename) { + if !e.isIncludeExt(filename) && !e.checkIncludeFile(filename) { continue } if e.config.Build.ExcludeUnchanged { diff --git a/runner/engine_test.go b/runner/engine_test.go index 12e4b7a2..b7a7c847 100644 --- a/runner/engine_test.go +++ b/runner/engine_test.go @@ -804,7 +804,7 @@ func TestShouldIncludeIncludedFile(t *testing.T) { [build] cmd = "true" # do nothing full_bin = "sh main.sh" -include_ext = ["sh"] +include_ext = [] include_dir = ["nonexist"] # prevent default "." watch from taking effect include_file = ["main.sh"] ` From 7ea1089dbf73f699cc1ca5dbca3b87e54e7af4b3 Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 29 Nov 2022 11:39:00 +0100 Subject: [PATCH 2/2] Fix argument to isIncludeExt --- runner/engine.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runner/engine.go b/runner/engine.go index d3421c16..822c0f01 100644 --- a/runner/engine.go +++ b/runner/engine.go @@ -186,7 +186,7 @@ func (e *Engine) cacheFileChecksums(root string) error { } } - if e.isExcludeFile(path) || !e.isIncludeExt(ev.Name) && !e.checkIncludeFile(path) { + if e.isExcludeFile(path) || !e.isIncludeExt(path) && !e.checkIncludeFile(path) { e.watcherDebug("!exclude checksum %s", e.config.rel(path)) return nil }