From 78d7ba126b0f79ee236562eaa987a60fb47ca5d7 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Fri, 11 Oct 2019 12:14:37 -0400 Subject: [PATCH 1/2] Make languageForFilePath work for .php files. As reported in #330, we're currently dying in `languageForFilePath` because `lingo` is giving us back Hack when we expect PHP. This is a pretty bad bug, so here's a temporary workaround for the issue. Once https://github.com/tclem/lingo-haskell/issues/3 is fixed, we can remove this workaround. Fixes #330. --- src/Data/Language.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Data/Language.hs b/src/Data/Language.hs index 8eaf0150e..358fd4539 100644 --- a/src/Data/Language.hs +++ b/src/Data/Language.hs @@ -129,6 +129,7 @@ textToLanguage :: T.Text -> Language textToLanguage = \case "Go" -> Go "Haskell" -> Haskell + "Hack" -> PHP -- working around https://github.com/github/semantic/issues/330 "Java" -> Java "JavaScript" -> JavaScript "JSON" -> JSON From 94caaab09ecdb16cafe5e07ee9a39b6c1b67dae8 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Fri, 11 Oct 2019 12:19:11 -0400 Subject: [PATCH 2/2] Add test cases so this doesn't happen again. --- test/Data/Language/Spec.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/Data/Language/Spec.hs b/test/Data/Language/Spec.hs index dcc2a8c01..a0864cb0b 100644 --- a/test/Data/Language/Spec.hs +++ b/test/Data/Language/Spec.hs @@ -8,6 +8,11 @@ testTree :: TestTree testTree = testGroup "Data.Language" [ testCase "supportedExts returns expected list" $ supportedExts @=? [".go",".java",".rb",".builder",".eye",".fcgi",".gemspec",".god",".jbuilder",".mspec",".pluginspec",".podspec",".rabl",".rake",".rbuild",".rbw",".rbx",".ru",".ruby",".spec",".thor",".watchr",".py",".bzl",".cgi",".fcgi",".gyp",".gypi",".lmi",".py3",".pyde",".pyi",".pyp",".pyt",".pyw",".rpy",".spec",".tac",".wsgi",".xpy",".js","._js",".bones",".es",".es6",".frag",".gs",".jake",".jsb",".jscad",".jsfl",".jsm",".jss",".mjs",".njs",".pac",".sjs",".ssjs",".xsjs",".xsjslib",".ts",".php",".aw",".ctp",".fcgi",".inc",".php3",".php4",".php5",".phps",".phpt"] + , testCase "codeNavLanguages returns expected list" $ codeNavLanguages @=? [Go, Java, Ruby, Python, JavaScript, TypeScript, PHP] + + , testCase "languageForFilePath works for languages with ambiguous lingo extensions" $ do + languageForFilePath "foo.php" @=? PHP + languageForFilePath "foo.md" @=? Markdown ]