Skip to content

Commit b1d86db

Browse files
committed
Only put .journal files in the generated include files. Fixes #92
1 parent 6b2ab73 commit b1d86db

File tree

7 files changed

+26
-10
lines changed

7 files changed

+26
-10
lines changed

ChangeLog.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog for [hledger-flow](https://github.com/apauley/hledger-flow)
22

3+
## 0.14.3
4+
5+
Ensure that generated include files only contain files ending with .journal
6+
7+
Fixes [#92](https://github.com/apauley/hledger-flow/issues/92)
8+
39
## 0.14.2
410

511
Add an optional `--start-year` command-line option for imports:

package.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: hledger-flow
2-
version: 0.14.2.0
2+
version: 0.14.3.0
33
synopsis: An hledger workflow focusing on automated statement import and classification.
44
category: Finance, Console
55
license: GPL-3

src/Hledger/Flow/Import/ImportHelpersTurtle.hs

+4-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ importDirBreakdown' acc path = do
5656
else importDirBreakdown' (dir:acc) $ Turtle.parent dir
5757

5858
groupIncludeFiles :: [TurtlePath] -> (TurtleFileBundle, TurtleFileBundle)
59-
groupIncludeFiles = allYearIncludeFiles . groupIncludeFilesPerYear
59+
groupIncludeFiles = allYearIncludeFiles . groupIncludeFilesPerYear . filter isJournalFile
60+
61+
isJournalFile :: TurtlePath -> Bool
62+
isJournalFile f = Turtle.extension f == Just "journal"
6063

6164
allYearIncludeFiles :: TurtleFileBundle -> (TurtleFileBundle, TurtleFileBundle)
6265
allYearIncludeFiles m = (m, yearsIncludeMap $ Map.keys m)

stack.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919
# resolver: ./custom-snapshot.yaml
2020
# resolver: https://example.com/snapshots/2018-01-01.yaml
21-
resolver: nightly-2021-01-05
21+
resolver: nightly-2021-02-06
2222

2323
# User packages to be built.
2424
# Various formats can be used as shown in the example below.

stack.yaml.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
packages: []
77
snapshots:
88
- completed:
9-
size: 562051
10-
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2021/1/5.yaml
11-
sha256: be105362ec57d665ea17fa574ab195c49bb1f9a5bd9016174ef83cd368fba253
12-
original: nightly-2021-01-05
9+
size: 565469
10+
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2021/2/6.yaml
11+
sha256: 7108f8cb8c928699c6c3c6574d3f6fc132db8bbba6a3987f9446fb35fd67dbf6
12+
original: nightly-2021-02-06

test/Common/Integration.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ testHiddenFiles = TestCase (
2323
let tmpHidden = map (tmpdir </>) hiddenFiles :: [TurtlePath]
2424
let onDisk = List.sort $ tmpJournals ++ tmpExtras ++ tmpHidden
2525
touchAll onDisk
26-
filtered <- (fmap List.sort) $ shellToList $ onlyFiles $ select onDisk
26+
filtered <- fmap List.sort $ shellToList $ onlyFiles $ select onDisk
2727
let expected = List.sort $ tmpExtras ++ tmpJournals
2828
liftIO $ assertEqual "Hidden files should be excluded" expected filtered
2929
)

test/TestHelpersTurtle.hs

+9-2
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,20 @@ inputFiles :: [TurtlePath]
4444
inputFiles = inputJohnBogart <> inputJohnOther <> inputJaneBogart <> inputJaneOther
4545

4646
journalFiles :: [TurtlePath]
47-
journalFiles = toJournals inputFiles
47+
journalFiles = toJournals inputFiles ++ ignoredJournalFiles
48+
49+
ignoredJournalFiles :: [TurtlePath]
50+
ignoredJournalFiles = ["import/john/bogartbank/checking/3-journal/2018/not-a-journal.pdf"]
4851

4952
extraFiles :: [TurtlePath]
5053
extraFiles = ["import/john/bogartbank/savings/2017-opening.journal"]
5154

5255
hiddenFiles :: [TurtlePath]
53-
hiddenFiles = [".hiddenfile", "checking/.DS_Store", "import/john/bogartbank/savings/1-in/.anotherhiddenfile", "import/john/bogartbank/checking/1-in/2018/.hidden"]
56+
hiddenFiles = [".hiddenfile",
57+
"checking/.DS_Store",
58+
"import/john/bogartbank/savings/1-in/.anotherhiddenfile",
59+
"import/john/bogartbank/checking/1-in/2018/.hidden",
60+
"import/john/bogartbank/checking/3-journal/2018/.hidden"]
5461

5562
toJournals :: [TurtlePath] -> [TurtlePath]
5663
toJournals = map (changePathAndExtension "3-journal" "journal")

0 commit comments

Comments
 (0)