ishepard / pydriller

Python Framework to analyse Git repositories

Home Page:http://pydriller.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to retrieve the entire patch from a Commit object in PyDriller?

41241241241 opened this issue · comments

Hi PyDriller team, thanks for your great package. I am wondering if there is currently a way to retrieve the entire patch string from a Commit object in PyDriller?

My team currently has a use case where we would like to store several artefacts from a commit into our database, including the full patch, in case we want to do our own custom parsing or processing. Reading the most recent version of the docs, I don't think this is currently possible (and honestly when I consider the main point of PyDriller, which IMO is to parse and process the patch info for us, it kind of makes sense that this might not be available). However as we are already using PyDriller, and we are assuming the package must be obtaining and maybe storing the entire patch in some way or another, I'm wondering if there is an some way we can get it from a Commit object, like "commit.patch". I know we can retrieve it using the Git API, or even scraping it from a URL such as "https://github.com/ishepard/pydriller/commit/250391839afcad3320e451c841090ccc69407e94.patch", but it would make it easier to just get it from PyDriller somehow. Thanks!

Hi @41241241241 ,

Can you please clarify what do you mean with "entire patch string of a Commit"? I assume you refer to the modifications of all the files in the commit.
In that case, you may want to take a look at the ModifiedFile object, which stores information about a file's diff, content before and after the commit, in addition to added and deleted lines.

Hope that helps!

There should be a way to retrieve the entire patch like what you linked: https://github.com/ishepard/pydriller/commit/250391839afcad3320e451c841090ccc69407e94.patch

ModifiedFile is just the "parsed" version of it.

Marking this as a PR, if anyone wants to pick it up.

@ishepard may I work on this?

@ishepard may I work on this?

I'd love that, thanks!