Skip to content

Commit

Permalink
Merge pull request #213 from github/git-ls-tree-fixes
Browse files Browse the repository at this point in the history
Git ls tree fixes
  • Loading branch information
tclem authored Aug 1, 2019
2 parents ff9e140 + 4fa9013 commit 72b3aed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion semantic.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Semantic/Git.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/Semantic/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 72b3aed

Please sign in to comment.