hapistrano 0.3.3.0 → 0.3.4.0
raw patch · 5 files changed
+49/−9 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ System.Hapistrano.Commands: GitCheckout :: String -> GitCheckout
+ System.Hapistrano.Commands: data GitCheckout
+ System.Hapistrano.Commands: instance System.Hapistrano.Commands.Command System.Hapistrano.Commands.GitCheckout
Files
- CHANGELOG.md +3/−0
- hapistrano.cabal +1/−1
- spec/System/HapistranoSpec.hs +28/−3
- src/System/Hapistrano.hs +5/−5
- src/System/Hapistrano/Commands.hs +12/−0
CHANGELOG.md view
@@ -1,3 +1,6 @@+## 0.3.4.0+* Use `git checkout` instead of `git reset` to set the release revision+ ## 0.3.3.0 * Correct bounds for base. GHC support for versions older than 7.10 was dropped on 0.3.0.0
hapistrano.cabal view
@@ -1,5 +1,5 @@ name: hapistrano-version: 0.3.3.0+version: 0.3.4.0 synopsis: A deployment library for Haskell applications description: .
spec/System/HapistranoSpec.hs view
@@ -17,6 +17,9 @@ import qualified System.Hapistrano.Core as Hap import qualified Test.Hspec as Hspec +testBranchName :: String+testBranchName = "another_branch"+ spec :: Spec spec = do describe "readScript" $@@ -33,7 +36,7 @@ , "cabal build -j" ] around withSandbox $ do- describe "pushRelease" $+ describe "pushRelease" $ do it "sets up repo all right" $ \(deployPath, repoPath) -> runHap $ do let task = mkTask deployPath repoPath release <- Hap.pushRelease task@@ -42,6 +45,18 @@ (liftIO . readFile . fromAbsFile) (rpath </> $(mkRelFile "foo.txt")) `shouldReturn` "Foo!\n" + it "deploys properly a branch other than master" $ \(deployPath, repoPath) -> runHap $ do+ let task = mkTaskWithCustomRevision deployPath repoPath testBranchName+ release <- Hap.pushRelease task+ rpath <- Hap.releasePath deployPath release+ -- let's check that the dir exists and contains the right files+ (liftIO . readFile . fromAbsFile) (rpath </> $(mkRelFile "bar.txt"))+ `shouldReturn` "Bar!\n"+ -- This fails if the opened branch is not testBranchName+ justExec rpath ("test `git rev-parse --abbrev-ref HEAD` = " ++ testBranchName)+ -- This fails if there are unstaged changes+ justExec rpath "git diff --exit-code"+ describe "registerReleaseAsComplete" $ it "creates the token all right" $ \(deployPath, repoPath) -> runHap $ do let task = mkTask deployPath repoPath@@ -163,7 +178,14 @@ justExec path "echo 'Foo!' > foo.txt" justExec path "git add -A" justExec path "git commit -m 'Initial commit'"+ -- Add dummy content to a branch that is not master+ justExec path ("git checkout -b " ++ testBranchName)+ justExec path "echo 'Bar!' > bar.txt"+ justExec path "git add bar.txt"+ justExec path "git commit -m 'Added more bars to another branch'"+ justExec path "git checkout master" + -- | Execute arbitrary commands in the specified directory. justExec :: Path Abs Dir -> String -> Hapistrano ()@@ -191,8 +213,11 @@ -- | Make a 'Task' given deploy path and path to the repo. mkTask :: Path Abs Dir -> Path Abs Dir -> Task-mkTask deployPath repoPath = Task+mkTask deployPath repoPath = mkTaskWithCustomRevision deployPath repoPath "master"++mkTaskWithCustomRevision :: Path Abs Dir -> Path Abs Dir -> String -> Task+mkTaskWithCustomRevision deployPath repoPath revision = Task { taskDeployPath = deployPath , taskRepository = fromAbsDir repoPath- , taskRevision = "master"+ , taskRevision = revision , taskReleaseFormat = ReleaseLong }
src/System/Hapistrano.hs view
@@ -193,17 +193,17 @@ let cpath = cacheRepoPath deployPath exec (GitClone False (Right cpath) rpath) --- | Set the release to the correct revision by resetting the head of the--- git repo.+-- | Set the release to the correct revision by checking out a branch or+-- a commit. setReleaseRevision :: Path Abs Dir -- ^ Deploy path- -> Release -- ^ 'Release' to reset- -> String -- ^ Revision to reset to+ -> Release -- ^ 'Release' to checkout+ -> String -- ^ Revision to checkout -> Hapistrano () setReleaseRevision deployPath release revision = do rpath <- releasePath deployPath release- exec (Cd rpath (GitReset revision))+ exec (Cd rpath (GitCheckout revision)) -- | Return a list of all currently deployed releases sorted newest first.
src/System/Hapistrano/Commands.hs view
@@ -27,6 +27,7 @@ , Readlink (..) , Find (..) , Touch (..)+ , GitCheckout (..) , GitClone (..) , GitFetch (..) , GitReset (..)@@ -202,6 +203,17 @@ renderCommand (Touch path) = formatCmd "touch" [ Just (fromAbsFile path) ] parseResult Proxy _ = ()++-- | Git checkout.++data GitCheckout = GitCheckout String++instance Command GitCheckout where+ type Result GitCheckout = ()+ renderCommand (GitCheckout revision) = formatCmd "git"+ [ Just "checkout"+ , Just revision ]+ parseResult Proxy _ = () -- | Git clone.