mirror of
https://github.com/github/semantic.git
synced 2024-12-25 16:02:43 +03:00
Add defaultPlainBlob
This commit is contained in:
parent
54c86748ad
commit
8ddc5eb000
@ -17,6 +17,10 @@ modeToDigits (SymlinkBlob mode) = showOct mode ""
|
||||
data SourceBlob = SourceBlob { source :: Source Char, oid :: String, path :: FilePath, blobKind :: Maybe SourceKind }
|
||||
deriving (Show, Eq)
|
||||
|
||||
-- | The default plain blob mode
|
||||
defaultPlainBlob :: SourceKind
|
||||
defaultPlainBlob = PlainBlob 0o100644
|
||||
|
||||
-- | The contents of a source file, backed by a vector for efficient slicing.
|
||||
newtype Source a = Source { getVector :: Vector.Vector a }
|
||||
deriving (Eq, Show, Functor, Traversable)
|
||||
|
@ -79,7 +79,7 @@ testDiff :: Renderer T.Text String -> Both FilePath -> Maybe FilePath -> (String
|
||||
testDiff renderer paths diff matcher = do
|
||||
let parser = parserForFilepath (fst paths)
|
||||
sources <- sequence $ readAndTranscodeFile <$> paths
|
||||
let sourceBlobs = Both (S.SourceBlob, S.SourceBlob) <*> sources <*> pure mempty <*> paths <*> pure (Just (S.PlainBlob 0o100644)
|
||||
let sourceBlobs = Both (S.SourceBlob, S.SourceBlob) <*> sources <*> pure mempty <*> paths <*> pure (Just S.defaultPlainBlob
|
||||
actual <- diffFiles parser renderer sourceBlobs
|
||||
case diff of
|
||||
Nothing -> matcher actual actual
|
||||
|
@ -13,4 +13,4 @@ spec :: Spec
|
||||
spec = parallel $
|
||||
describe "hunks" $
|
||||
it "empty diffs have empty hunks" $
|
||||
hunks (Free . Annotated (pure (Info (Range 0 0) mempty)) $ Leaf "") (Both (SourceBlob (fromList "") "abcde" "path2.txt" (Just (PlainBlob 0o100644)), SourceBlob (fromList "") "xyz" "path2.txt" (Just (PlainBlob 0o100644)))) `shouldBe` [Hunk {offset = Both (0, 0), changes = [], trailingContext = []}]
|
||||
hunks (Free . Annotated (pure (Info (Range 0 0) mempty)) $ Leaf "") (Both (SourceBlob (fromList "") "abcde" "path2.txt" (Just defaultPlainBlob), SourceBlob (fromList "") "xyz" "path2.txt" (Just defaultPlainBlob))) `shouldBe` [Hunk {offset = Both (0, 0), changes = [], trailingContext = []}]
|
||||
|
Loading…
Reference in New Issue
Block a user