diff --git a/internal/paths/paths.go b/internal/paths/paths.go index 9348f5d..2343a9b 100644 --- a/internal/paths/paths.go +++ b/internal/paths/paths.go @@ -9,6 +9,8 @@ import ( "github.com/phrase/phraseapp-client/internal/shared" ) +var YamlConfigName = ".phraseapp.yml" + func Validate(file, formatName, formatExtension string) error { if strings.TrimSpace(file) == "" { return fmt.Errorf("File patterns may not be empty!\nFor more information see %s", shared.DocsConfigUrl) @@ -56,3 +58,7 @@ func Segments(s string) []string { return strings.FieldsFunc(filepath.Clean(s), func(c rune) bool { return c == filepath.Separator }) } + +func IsPhraseAppYmlConfig(path string) bool { + return strings.Contains(filepath.Base(path), YamlConfigName) +} diff --git a/internal/paths/paths_test.go b/internal/paths/paths_test.go new file mode 100644 index 0000000..8ab7413 --- /dev/null +++ b/internal/paths/paths_test.go @@ -0,0 +1,33 @@ +package paths + +import ( + "testing" +) + +func TestIsPhraseAppYamlConfig(t *testing.T) { + tests := []struct { + test string + expect bool + }{ + { + test: "abc/*/.phraseapp.yml", + expect: true, + }, { + test: "abc/*/abc.phraseapp.yml", + expect: true, + }, { + test: "abc/*/.phraseapp.yml/lol.yml", + expect: false, + }, { + test: "abc/*/.phraseapp.yml/.yml", + expect: false, + }, + } + + for _, test := range tests { + was := IsPhraseAppYmlConfig(test.test) + if was != test.expect { + t.Fatalf("expected %q to yield %v, but was: %v", test.test, test.expect, was) + } + } +} diff --git a/push.go b/push.go index 866a4e0..982b891 100644 --- a/push.go +++ b/push.go @@ -161,6 +161,10 @@ func (source *Source) LocaleFiles() (LocaleFiles, error) { var localeFiles LocaleFiles for _, path := range filePaths { + if paths.IsPhraseAppYmlConfig(path) { + continue + } + localeFile := new(LocaleFile) localeFile.fillFromPath(path, source.File) diff --git a/push_test.go b/push_test.go index 2df1482..677aba1 100644 --- a/push_test.go +++ b/push_test.go @@ -251,6 +251,8 @@ func setupLocalesFiles(t *testing.T) (dir string) { "b/YY/c/d.txt", "b/YY/foo.bar.json", "b/YY/foo.json", + "b/XX/.phraseapp.yml", + "b/XX/en.yml", } files = append(files, []string{ "config/locales/application.en.yml", @@ -356,6 +358,7 @@ func TestLocaleFiles(t *testing.T) { {"b/YY/foo.json", "", "foo", "", false}, {"b/YY/foo.bar.json", "", "foo.bar", "", false}, // weird locale! }}, + {"b/XX/.yml", []localeFile{{"b/XX/en.yml", "", "en", "", false}}}, } for _, tti := range tt {