diff options
author | Azul <azul@riseup.net> | 2013-09-16 09:06:49 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2013-09-16 09:12:12 +0200 |
commit | adbe5e98e61855c71d73539fa8dba917a82b111a (patch) | |
tree | 923a35224076cd06efd60e22a78d981547fd8a16 /files | |
parent | 514e226addc51cdd098049152c11ce1cd882bd1a (diff) |
Improve couch doc diff (#3761)
Both the couch document and the second paramter will be pretty printed
before comparison so differences in spaces etc. do not matter.
All keys starting with an underscore on the couch such as _id and _rev
will be removed before the comparison - we assume we want to compare
the real data, not the metadata about the document as we usually do not
know or care about what the id and revision will be.
Diffstat (limited to 'files')
-rw-r--r-- | files/couch-doc-diff | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/files/couch-doc-diff b/files/couch-doc-diff index 5438eab..a5907d5 100644 --- a/files/couch-doc-diff +++ b/files/couch-doc-diff @@ -1,2 +1,17 @@ #!/bin/bash -diff -w <(curl -s --netrc-file /etc/couchdb/couchdb.netrc $1 ) <(echo $2) + +# Run a diff between a couch document specified as the first parameter +# and the second parameter. +# Diff returns 0 if there is no difference. This way you can tell the data +# is already on the couch. +# Both the couch document and the second paramter will be pretty printed +# before comparison so differences in spaces etc. do not matter. +# All keys starting with an underscore on the couch such as _id and _rev +# will be removed before the comparison - we assume we want to compare +# the real data, not the metadata about the document as we usually do not +# know or care about what the id and revision will be. + +curl -s --netrc-file /etc/couchdb/couchdb.netrc $1 \ + | python -mjson.tool \ + | grep -v '^\s*"_' \ + | diff -w - <(echo $2 | python -mjson.tool) |