hledger-flow 0.12.3.0 → 0.12.3.1
raw patch · 4 files changed
+51/−37 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +16/−0
- hledger-flow.cabal +2/−2
- src/Hledger/Flow/Common.hs +3/−1
- test/Common/Integration.hs +30/−34
ChangeLog.md view
@@ -1,5 +1,21 @@ # Changelog for [hledger-flow](https://github.com/apauley/hledger-flow) +## 0.12.3.1++Fixed a bug where:++Given:+- A run of `hledger-flow import`++When:+- specifying a relative import base directory+- but specifically without any relative prefixes such as `./` or `../`++Then:+- the account-level include files pointing to the real journal entries would have incorrect paths++https://github.com/apauley/hledger-flow/issues/65+ ## 0.12.3 Add more reports:
hledger-flow.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 238554ba5f9f4fbeff3effd7709b051f2e6d5e4386d56f57aa1c7de2241a6727+-- hash: bc3f43f1b0698c9441147d8c7a211cde2bfbaaa5d5366ad7b17e1479584cfe78 name: hledger-flow-version: 0.12.3.0+version: 0.12.3.1 synopsis: An hledger workflow focusing on automated statement import and classification. description: Please see the README on GitHub at <https://github.com/apauley/hledger-flow#readme> category: Finance, Console
src/Hledger/Flow/Common.hs view
@@ -427,7 +427,9 @@ determineBaseDir' :: FilePath -> IO FilePath determineBaseDir' startDir = do- ebd <- determineBaseDir'' startDir startDir+ currentDir <- pwd+ let absoluteStartDir = if relative startDir then collapse (currentDir </> startDir) else startDir+ ebd <- determineBaseDir'' absoluteStartDir absoluteStartDir case ebd of Right bd -> return bd Left t -> die t
test/Common/Integration.hs view
@@ -7,6 +7,7 @@ import Turtle import Prelude hiding (FilePath) import qualified Data.List as List (sort)+import qualified Data.Text as T import TestHelpers import Hledger.Flow.Common@@ -49,6 +50,23 @@ ) ) +assertSubDirsForDetermineBaseDir :: FilePath -> [FilePath] -> IO ()+assertSubDirsForDetermineBaseDir expectedBaseDir importDirs = do+ _ <- sequence $ map (assertDetermineBaseDir expectedBaseDir) importDirs+ return ()++assertDetermineBaseDir :: FilePath -> FilePath -> IO ()+assertDetermineBaseDir expectedBaseDir subDir = do+ initialPwd <- pwd+ bd1 <- determineBaseDir $ Just subDir+ cd subDir+ bd2 <- determineBaseDir Nothing+ bd3 <- determineBaseDir $ Just "."+ cd initialPwd+ let msg = format ("determineBaseDir searches from pwd upwards until it finds a dir containing 'import' - "%fp) subDir+ _ <- sequence $ map (assertEqual (T.unpack msg) expectedBaseDir) [bd1, bd2, bd3]+ return ()+ testDetermineBaseDir :: Test testDetermineBaseDir = TestCase ( sh (@@ -63,51 +81,29 @@ bdUnrelated <- liftIO $ determineBaseDir'' unrelatedDir unrelatedDir liftIO $ assertEqual "determineBaseDir produces an error message when it cannot find a baseDir" (Left $ errorMessageBaseDir unrelatedDir) bdUnrelated - currentDir <- pwd- let baseDir = forceTrailingSlash $ collapse $ currentDir </> tmpdir </> "bd1"-+ let baseDir = "bd1" let importDir = baseDir </> "import" let ownerDir = importDir </> "john" let bankDir = ownerDir </> "mybank" let accDir = bankDir </> "myacc" let inDir = accDir </> "1-in" let yearDir = inDir </> "2019"- mktree yearDir-- let reportDir = baseDir </> "report"- mkdir reportDir-- cd baseDir- bd <- liftIO $ determineBaseDir Nothing- liftIO $ assertEqual "determineBaseDir searches from pwd upwards until it finds a dir containing 'import' - in the base dir" baseDir bd-- cd reportDir- bdReport <- liftIO $ determineBaseDir Nothing- liftIO $ assertEqual "determineBaseDir searches from pwd upwards until it finds a dir containing 'import' - report dir" baseDir bdReport-- cd yearDir- bdYear <- liftIO $ determineBaseDir Nothing- liftIO $ assertEqual "determineBaseDir searches from pwd upwards until it finds a dir containing 'import' - year dir" baseDir bdYear+ let subDirs = [yearDir, inDir, accDir, bankDir, ownerDir, importDir, baseDir] - cd inDir- bdIn <- liftIO $ determineBaseDir Nothing- liftIO $ assertEqual "determineBaseDir searches from pwd upwards until it finds a dir containing 'import' - input dir" baseDir bdIn+ mktree $ tmpdir </> yearDir - cd accDir- bdAcc <- liftIO $ determineBaseDir Nothing- liftIO $ assertEqual "determineBaseDir searches from pwd upwards until it finds a dir containing 'import' - account dir" baseDir bdAcc+ let subDirsRelativeToTop = map (tmpdir </>) subDirs - cd bankDir- bdBank <- liftIO $ determineBaseDir Nothing- liftIO $ assertEqual "determineBaseDir searches from pwd upwards until it finds a dir containing 'import' - bank dir" baseDir bdBank+ currentDir <- pwd+ let absoluteTempDir = forceTrailingSlash $ collapse $ currentDir </> tmpdir+ let absoluteSubDirs = map (absoluteTempDir </>) subDirs - cd ownerDir- bdOwner <- liftIO $ determineBaseDir Nothing- liftIO $ assertEqual "determineBaseDir searches from pwd upwards until it finds a dir containing 'import' - owner dir" baseDir bdOwner+ let absoluteBaseDir = forceTrailingSlash $ absoluteTempDir </> baseDir+ liftIO $ assertSubDirsForDetermineBaseDir absoluteBaseDir absoluteSubDirs+ liftIO $ assertSubDirsForDetermineBaseDir absoluteBaseDir subDirsRelativeToTop - cd importDir- bdImport <- liftIO $ determineBaseDir Nothing- liftIO $ assertEqual "determineBaseDir searches from pwd upwards until it finds a dir containing 'import' - import dir" baseDir bdImport+ cd absoluteTempDir+ liftIO $ assertSubDirsForDetermineBaseDir absoluteBaseDir subDirs ) )