deepdiff
deepdiff copied to clipboard
How to use `deepdiff` as the difftool of git?
hi,
I have to manage a batch of yaml/json files under git, the default git diff
shows the text line based diff, which make no sense for object differences in yaml/json files. deepdiff
provides a wonderful view in this scenario, is it possible to use deepdiff
as the git's difftool?
thanks
Hi @immarvin I don't think we can replace git diff with deep diff because they act very differently. But perhaps we can add a command line tool for deepdiff that can be used to separately compare files.
hi @seperman ,thanks for the information. I managed to create a wrapper script(https://github.com/xcat2/xcat-inventory/pull/83) and apply it as the diff tool in git.
Attach the steps here for those who is interested in this:
~: export PATH=$PATH:<PATH_TO_DIFF_SCRIPT_DIR>
~: git config --global diff.tool <DIFF_SCRIPT_NAME>
~: git config --global difftool.<DIFF_SCRIPT_NAME>.cmd '<DIFF_SCRIPT_NAME> $REMOTE $LOCAL $MERGED'
#$REMOTE $LOCAL $MERGED are variables passed to the <DIFF_SCRIPT> by git.
after the steps above, we can use git difftool
instead of git diff
to show the differences with deepdiff, all the arguments are the same
Hi @immarvin I'm releasing a new version of DeepDiff and I was wondering if I can put your script as a part of the DeepDiff package. I don't see a license on https://github.com/xcat2/xcat-inventory Can you please let me know if I can copy paste the code from the xcat-inventory? Also I have ended Python 2 support but looking at your code, I assume you are using Pythong 2. Thanks! Sep
hi @seperman , our license is supposed to be EPL. I need to check with the team tomorrow to get the permission.
Which piece of code do you want? what feature would you like to add in the new release with these code pieces?
ps, these 2 files https://github.com/xcat2/xcat-inventory/blob/master/xcat-inventory/xcclient/inventory/inventorydiff.py and https://github.com/xcat2/xcat-inventory/blob/master/xcat-inventory/xcclient/inventory/structurediff.py are latest wrapper scripts
Hi @immarvin Thanks for the quick response. Yes I was referring to those 2 files. I just released v4.0.0 but would like to add those 2 files and modify them slightly in the next release if possible. Please let me know! I can either copy paste the code or you can open a PR. Thanks, Sep
hi @seperman , checked with the team today, we are ok to contribute these 2 files. We will create a PR in our working hours(which branch should the PR be targeted against? "master" ?) in this repo and let you know.
Currently, you may need to polish the files according to the deepdiff code logic by yourself.
Please let us know when this feature is ok, so that xcat-inventory
can leverage the new interface and the duplicate code can be removed
Hi @immarvin Awesome! Please make the PR against the dev branch: https://github.com/seperman/deepdiff#contribute Thanks!
hi @seperman , the author of the 2 files @xuweibj has create the PR https://github.com/seperman/deepdiff/pull/128
Hi @immarvin Thank you very much. Merged the PR. Will be modifying them and adding some docs soon. Will close this ticket once the changes are published on Pypi.