shithub: hugo

Download patch

ref: f271faea066c47817c8a9a62ef5509a151452d6a
parent: 5581e33a34ce852594ba03c3c7f0c067062d1358
author: Christoph Burgdorf <[email protected]>
date: Mon Apr 14 19:25:54 EDT 2014

Don't process dotfiles

This commit makes it so that not only files
but also folders which start with a dot
are ignored.

Fixes #239

--- a/source/content_directory_test.go
+++ b/source/content_directory_test.go
@@ -4,11 +4,13 @@
 	"testing"
 )
 
-func TestIgnoreDotFiles(t *testing.T) {
+func TestIgnoreDotFilesAndDirectories(t *testing.T) {
 	tests := []struct {
 		path   string
 		ignore bool
 	}{
+		{".foobar/", true },
+		{"foobar/.barfoo/", true },
 		{"barfoo.md", false},
 		{"foobar/barfoo.md", false},
 		{"foobar/.barfoo.md", true},
@@ -22,7 +24,7 @@
 	}
 
 	for _, test := range tests {
-		if ignored := ignoreDotFile(test.path); test.ignore != ignored {
+		if ignored := isNonProcessablePath(test.path); test.ignore != ignored {
 			t.Errorf("File not ignored.  Expected: %t, got: %t", test.ignore, ignored)
 		}
 	}
--- a/source/filesystem.go
+++ b/source/filesystem.go
@@ -87,12 +87,12 @@
 		}
 
 		if fi.IsDir() {
-			if f.avoid(filePath) {
+			if f.avoid(filePath) || isNonProcessablePath(filePath) {
 				return filepath.SkipDir
 			}
 			return nil
 		} else {
-			if ignoreDotFile(filePath) {
+			if isNonProcessablePath(filePath) {
 				return nil
 			}
 			data, err := ioutil.ReadFile(filePath)
@@ -116,7 +116,7 @@
 	return false
 }
 
-func ignoreDotFile(filePath string) bool {
+func isNonProcessablePath(filePath string) bool {
 	base := filepath.Base(filePath)
 	if base[0] == '.' {
 		return true