-
Notifications
You must be signed in to change notification settings - Fork 451
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #212 from github/from-paths
New options for readBlobsFromGitRepo
- Loading branch information
Showing
4 changed files
with
55 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,12 +31,46 @@ spec = do | |
git ["config", "user.email", "'[email protected]'"] | ||
git ["commit", "-am", "'test commit'"] | ||
|
||
readBlobsFromGitRepo (dir </> ".git") (Git.OID "HEAD") [] | ||
readBlobsFromGitRepo (dir </> ".git") (Git.OID "HEAD") [] [] | ||
let files = sortOn fileLanguage (blobFile <$> blobs) | ||
files `shouldBe` [ File "foo.py" Python | ||
, File "bar.rb" Ruby | ||
] | ||
|
||
when hasGit . it "should read from a git directory with --only" $ do | ||
-- This temporary directory will be cleaned after use. | ||
blobs <- liftIO . withSystemTempDirectory "semantic-temp-git-repo" $ \dir -> do | ||
shelly $ silently $ do | ||
cd (fromString dir) | ||
let git = run_ "git" | ||
git ["init"] | ||
run_ "touch" ["foo.py", "bar.rb"] | ||
git ["add", "foo.py", "bar.rb"] | ||
git ["config", "user.name", "'Test'"] | ||
git ["config", "user.email", "'[email protected]'"] | ||
git ["commit", "-am", "'test commit'"] | ||
|
||
readBlobsFromGitRepo (dir </> ".git") (Git.OID "HEAD") [] ["foo.py"] | ||
let files = sortOn fileLanguage (blobFile <$> blobs) | ||
files `shouldBe` [ File "foo.py" Python ] | ||
|
||
when hasGit . it "should read from a git directory with --exclude" $ do | ||
-- This temporary directory will be cleaned after use. | ||
blobs <- liftIO . withSystemTempDirectory "semantic-temp-git-repo" $ \dir -> do | ||
shelly $ silently $ do | ||
cd (fromString dir) | ||
let git = run_ "git" | ||
git ["init"] | ||
run_ "touch" ["foo.py", "bar.rb"] | ||
git ["add", "foo.py", "bar.rb"] | ||
git ["config", "user.name", "'Test'"] | ||
git ["config", "user.email", "'[email protected]'"] | ||
git ["commit", "-am", "'test commit'"] | ||
|
||
readBlobsFromGitRepo (dir </> ".git") (Git.OID "HEAD") ["foo.py"] [] | ||
let files = sortOn fileLanguage (blobFile <$> blobs) | ||
files `shouldBe` [ File "bar.rb" Ruby ] | ||
|
||
describe "readFile" $ do | ||
it "returns a blob for extant files" $ do | ||
Just blob <- readBlobFromFile (File "semantic.cabal" Unknown) | ||
|
@@ -109,4 +143,3 @@ spec = do | |
|
||
jsonException :: Selector InvalidJSONException | ||
jsonException = const True | ||
|