src-d / gitbase

SQL interface to git repositories, written in Go. https://docs.sourced.tech/gitbase
Apache License 2.0
2.06k stars 124 forks source link

How to find the exact changes for each file in a commit like git diff #959

Closed lcwj3 closed 4 years ago

lcwj3 commented 5 years ago

Hi, this is a powerful tool for parsing git repos. Currently I am trying to find a solution to parse exact line changes in each file for each commit, like git diff. I have read your code, it seems you are also using another tool https://github.com/hhatto/gocloc to count cloc (Maybe I didn't find the right place). Do you have a API or just a solution on parsing the exact changes for files? Looking forward to your reply, thanks for your attention!

ajnavarro commented 4 years ago

Hello @lcwj3 !

To check changes we actually have the following functions (https://docs.sourced.tech/gitbase/using-gitbase/functions#gitbase-functions):

Hope it helps.

lcwj3 commented 4 years ago

Hi, thanks for your kind reply. I have tried these two API, but it seems these two can only give how many lines are changed in each file, but not exact changed line contents as what git diff does.

ajnavarro commented 4 years ago

Sadly we don't have a way to get the content of those changed lines yet. We started some research on how to represent that on a tabular way, but right now is not in the immediate backlog.

lcwj3 commented 4 years ago

Okay, Thanks anyway! I was using unidiff to get the changed content, which can wrap a commit as a patch, then can access the exact lines, and I think the format in patch is good enough for me. Maybe this can help you a bit. And I will close this issue now, thanks!