Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@fujimura
Created July 13, 2013 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fujimura/5990335 to your computer and use it in GitHub Desktop.
Save fujimura/5990335 to your computer and use it in GitHub Desktop.
Clone git repo in temporary directory and do `ls-files`
import Control.Exception (bracket_)
import System.Directory
import System.Exit (ExitCode)
import System.IO.Temp (withSystemTempDirectory)
import System.Process (system)
inTemporaryDirectory :: String -> IO a -> IO a
inTemporaryDirectory name cb =
withSystemTempDirectory name $ flip inDirectory cb
inDirectory :: FilePath -> IO a -> IO a
inDirectory path cb = do
pwd <- getCurrentDirectory
bracket_ (setCurrentDirectory path) (setCurrentDirectory pwd) cb
cloneRepo :: String -> IO ExitCode
cloneRepo repoUrl = do
system $ "git clone --no-checkout --depth=1 --quiet " ++ repoUrl ++ " ./"
system "git checkout HEAD --quiet"
main :: IO ()
main =
inTemporaryDirectory "boilerplate" $ do
cloneRepo "git@github.com:fujimura/wai-hspec-example.git"
system "git ls-files"
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment