From 77b6b85d49f1f43c2fdfc58322259e73b6f356b4 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Wed, 31 Jul 2019 09:42:05 -0700 Subject: [PATCH 1/3] Properly parse other objects and modes --- src/Semantic/Git.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Semantic/Git.hs b/src/Semantic/Git.hs index 4923dcb0ce..903023c523 100644 --- a/src/Semantic/Git.hs +++ b/src/Semantic/Git.hs @@ -60,8 +60,8 @@ entryParser = TreeEntry <*> oidParser <* AP.char '\t' <*> (unpack <$> AP.takeWhile (/= '\NUL')) where - typeParser = AP.choice [BlobObject <$ "blob", TreeObject <$ "tree"] - modeParser = AP.choice [NormalMode <$ "100644", ExecutableMode <$ "100755", SymlinkMode <$ "120000", TreeMode <$ "040000"] + typeParser = AP.choice [BlobObject <$ "blob", TreeObject <$ "tree", OtherObjectType <$ AP.takeWhile isAlphaNum] + modeParser = AP.choice [NormalMode <$ "100644", ExecutableMode <$ "100755", SymlinkMode <$ "120000", TreeMode <$ "040000", OtherMode <$ AP.takeWhile isAlphaNum] oidParser = OID <$> AP.takeWhile isHexDigit newtype OID = OID Text From 61186c946d487415ad277b399b30a67db9d18b7d Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Wed, 31 Jul 2019 09:45:17 -0700 Subject: [PATCH 2/3] ++0.7.0.0 --- semantic.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/semantic.cabal b/semantic.cabal index d360dc1824..d0cb1fce5a 100644 --- a/semantic.cabal +++ b/semantic.cabal @@ -1,7 +1,7 @@ cabal-version: 2.4 name: semantic -version: 0.6.0.0 +version: 0.7.0.0 synopsis: Framework and executable for analyzing and diffing untrusted code. description: Semantic is a library for parsing, analyzing, and comparing source code across many languages. homepage: http://github.com/github/semantic#readme From 4fa9013e92ca585ac9e1cd18c7767f93f996ec21 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Wed, 31 Jul 2019 15:22:31 -0600 Subject: [PATCH 3/3] Add a test for other types and modes --- test/Semantic/Spec.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/Semantic/Spec.hs b/test/Semantic/Spec.hs index 91a3b1d254..a73c7233ec 100644 --- a/test/Semantic/Spec.hs +++ b/test/Semantic/Spec.hs @@ -44,5 +44,10 @@ spec = do let expected = [ TreeEntry NormalMode TreeObject (OID "abcdef") "/this/is/the/path", TreeEntry SymlinkMode BlobObject (OID "17776") "/dev/urandom"] parseEntries input `shouldBe` expected + it "parses submodules and other types" $ do + let input = "160000 commit 50865e8895c54037bf06c4c1691aa925d030a59d\tgemoji" + let expected = Right $ TreeEntry OtherMode OtherObjectType (OID "50865e8895c54037bf06c4c1691aa925d030a59d") "gemoji" + parseEntry input `shouldBe` expected + where methodsBlob = makeBlob "def foo\nend\n" "methods.rb" Ruby mempty