Decoupled functions from using .hapistrano_deploy_state filename directly

This commit is contained in:
DavidMazarro 2022-02-02 15:16:16 +01:00
parent b55d5bb9fc
commit fd4fdc68d3
No known key found for this signature in database
GPG Key ID: 5B490A04990FAAB7
3 changed files with 11 additions and 6 deletions

View File

@ -157,11 +157,11 @@ spec = do
-- This fails if there are unstaged changes
justExec rpath "git diff --exit-code"
describe "createHapistranoDeployState" $ do
it "creates the .hapistrano_deploy_state file correctly" $ \(deployPath, repoPath) ->
it ("creates the " <> deployStateFilename <> " file correctly") $ \(deployPath, repoPath) ->
runHap $ do
let task = mkTask deployPath repoPath
release <- Hap.pushRelease task
parseStatePath <- parseRelFile ".hapistrano_deploy_state"
parseStatePath <- parseRelFile deployStateFilename
actualReleasePath <- releasePath deployPath release Nothing
let stateFilePath = actualReleasePath </> parseStatePath
Hap.createHapistranoDeployState deployPath release Success
@ -194,7 +194,7 @@ spec = do
task = mkTask deployPath repoPath
Hap.playScriptLocally localCommands
release <- Hap.pushRelease task
parseStatePath <- parseRelFile ".hapistrano_deploy_state"
parseStatePath <- parseRelFile deployStateFilename
actualReleasePath <- releasePath deployPath release Nothing
let stateFilePath = actualReleasePath </> parseStatePath
Hap.createHapistranoDeployState deployPath release Success

View File

@ -45,6 +45,7 @@ import Path
import System.Hapistrano.Commands
import System.Hapistrano.Core
import System.Hapistrano.Types
import System.Hapistrano.Config (deployStateFilename)
import Text.Read (readMaybe)
----------------------------------------------------------------------------
@ -127,7 +128,7 @@ createHapistranoDeployState
-> DeployState -- ^ Indicates how the deployment went
-> Hapistrano ()
createHapistranoDeployState deployPath release state = do
parseStatePath <- parseRelFile ".hapistrano_deploy_state"
parseStatePath <- parseRelFile deployStateFilename
actualReleasePath <- releasePath deployPath release Nothing
let stateFilePath = actualReleasePath </> parseStatePath
exec (Touch stateFilePath) (Just release) -- creates '.hapistrano_deploy_state'
@ -361,7 +362,7 @@ deployState
-> Release -- ^ 'Release' identifier
-> Hapistrano (Maybe DeployState) -- ^ Whether the release was deployed successfully or not
deployState deployPath mWorkingDir release = do
parseStatePath <- parseRelFile ".hapistrano_deploy_state"
parseStatePath <- parseRelFile deployStateFilename
actualReleasePath <- releasePath deployPath release mWorkingDir
let stateFilePath = actualReleasePath </> parseStatePath
doesExist <- exec (CheckExists stateFilePath) (Just release)

View File

@ -7,7 +7,8 @@
module System.Hapistrano.Config
( Config (..)
, CopyThing (..)
, Target (..))
, Target (..)
, deployStateFilename)
where
import Control.Applicative ((<|>))
@ -141,3 +142,6 @@ mkCmd raw =
case mkGenericCommand raw of
Nothing -> fail "invalid restart command"
Just cmd -> return cmd
deployStateFilename :: String
deployStateFilename = ".hapistrano_deploy_state"