8000 Merge pull request #213 from github/git-ls-tree-fixes · github/semantic@72b3aed · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 72b3aed

Browse files
authored
Merge pull request #213 from github/git-ls-tree-fixes
Git ls tree fixes
2 parents ff9e140 + 4fa9013 commit 72b3aed

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

semantic.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 2.4
22

33
name: semantic
4-
version: 0.6.0.0
4+
version: 0.7.0.0
55
synopsis: Framework and executable for analyzing and diffing untrusted code.
66
description: Semantic is a library for parsing, analyzing, and comparing source code across many languages.
77
homepage: http://github.com/github/semantic#readme

src/Semantic/Git.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ entryParser = TreeEntry
6060
<*> oidParser <* AP.char '\t'
6161
<*> (unpack <$> AP.takeWhile (/= '\NUL'))
6262
where
63-
typeParser = AP.choice [BlobObject <$ "blob", TreeObject <$ "tree"]
64-
modeParser = AP.choice [NormalMode <$ "100644", ExecutableMode <$ "100755", SymlinkMode <$ "120000", TreeMode <$ "040000"]
63+
typeParser = AP.choice [BlobObject <$ "blob", TreeObject <$ "tree", OtherObjectType <$ AP.takeWhile isAlphaNum]
64+
modeParser = AP.choice [NormalMode <$ "100644", ExecutableMode <$ "100755", SymlinkMode <$ "120000", TreeMode <$ "040000", OtherMode <$ AP.takeWhile isAlphaNum]
6565
oidParser = OID <$> AP.takeWhile isHexDigit
6666

6767
newtype OID = OID Text

test/Semantic/Spec.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,10 @@ spec = do
4444
let expected = [ TreeEntry NormalMode TreeObject (OID "abcdef") "/this/is/the/path", TreeEntry SymlinkMode BlobObject (OID "17776") "/dev/urandom"]
4545
parseEntries input `shouldBe` expected
4646

47+
it "parses submodules and other types" $ do
48+
let input = "160000 commit 50865e8895c54037bf06c4c1691aa925d030a59d\tgemoji"
49+
let expected = Right $ TreeEntry OtherMode OtherObjectType (OID "50865e8895c54037bf06c4c1691aa925d030a59d") "gemoji"
50+
parseEntry input `shouldBe` expected
51+
4752
where
4853
methodsBlob = makeBlob "def foo\nend\n" "methods.rb" Ruby mempty

0 commit comments

Comments
 (0)
0