aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2018-02-16 13:27:17 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2018-02-16 13:27:17 -0400
commit6905149580cca206101dbdbcc88cc8a1d21a4088 (patch)
tree2d70596e8fed37c829ec5bfb5baacf6d46462691
parent6da003b9b7541e269e50add175be15b63009aa79 (diff)
--json: multi-line notes
--json: When there are multiple lines of notes about a file, make the note field multiline, rather than the old behavior of only including the last line. Using newlines in the note is perhaps not ideal, but upgrading it to an array in this case would be an annoying inconsistency to need to deal with. This commit was sponsored by Ole-Morten Duesund on Patreon.
-rw-r--r--CHANGELOG3
-rw-r--r--Messages/JSON.hs6
2 files changed, 8 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index be4811d75..3ce76debb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,9 @@ git-annex (6.20180113) UNRELEASED; urgency=medium
requires it.
* Add gpg-agent to Build-Depends.
Needed to run the test suite.
+ * --json: When there are multiple lines of notes about a file, make the note
+ field multiline, rather than the old behavior of only including the
+ last line.
-- Joey Hess <id@joeyh.name> Wed, 24 Jan 2018 20:42:55 -0400
diff --git a/Messages/JSON.hs b/Messages/JSON.hs
index 6ca3c1383..9b9ca67cf 100644
--- a/Messages/JSON.hs
+++ b/Messages/JSON.hs
@@ -75,8 +75,12 @@ end b (Just (o, _)) = Just (HM.insert "success" (toJSON b) o, True)
end _ Nothing = Nothing
note :: String -> JSONBuilder
-note s (Just (o, e)) = Just (HM.insert "note" (toJSON s) o, e)
note _ Nothing = Nothing
+note s (Just (o, e)) = Just (HM.insertWith combinelines "note" (toJSON s) o, e)
+ where
+ combinelines (String new) (String old) =
+ String (old <> T.pack "\n" <> new)
+ combinelines new _old = new
info :: String -> JSONBuilder
info s _ = Just (o, True)