ソースを参照

Made VariadicFields ignore dotfiles

arianagiroux 3 週間 前
コミット
8851293f9b

+ 4 - 0
bug.go

@@ -110,6 +110,10 @@ func (vf VariadicField) NewFromPath(pathOnDisk string) (v VariadicField, err err
 		if err != nil {
 			return vf, err
 		}
+		if file.Name()[0:1] == "." {
+			continue
+		}
+
 		vf.Fields = append(vf.Fields, Field{Data: data, Path: file.Name()})
 	}
 

+ 8 - 0
bug_test.go

@@ -110,6 +110,14 @@ func Test_VariadicField_NewFromPath_no_tags_in_dir(t *testing.T) {
 	assert.Equal(t, len(vf.Fields), 0)
 }
 
+func Test_VariadicField_NewFromPath_skip_dotfile(t *testing.T) {
+	vf, err := VariadicField.NewFromPath(VariadicField{Path: "/tags"}, "tests/bugs/test-4")
+	if err != nil {
+		assert.Fail(t, "should not throw error")
+	}
+	assert.Equal(t, len(vf.Fields), 2)
+}
+
 func Test_VariadicField_NewFromPath_success(t *testing.T) {
 	vf, err := VariadicField.NewFromPath(VariadicField{Path: "/tags"}, "tests/bugs/test-1")
 	if err != nil {

+ 0 - 0
tests/bugs/test-4/blockedby/blocker1


+ 0 - 0
tests/bugs/test-4/blockedby/blocker2


+ 1 - 0
tests/bugs/test-4/description

@@ -0,0 +1 @@
+test description

+ 1 - 0
tests/bugs/test-4/status

@@ -0,0 +1 @@
+open:test

+ 0 - 0
tests/bugs/test-4/tags/.gitignore


+ 0 - 0
tests/bugs/test-4/tags/tag1


+ 0 - 0
tests/bugs/test-4/tags/tag2