ishepard/pydriller

Is there a way to get the absolute path of the cloned repo?

hatrg opened this issue · 3 comments

hatrg commented

Problem:

I have a workflow with pydriller where after I cloned and analyzed the repo, I need to pass the cloned local files (let's call it the artifact) to the next step and then perform some actions to it.

So I kind of need to have the full absolute path of the artifact, I tried to use the static Repository._clone_folder method but it returns the tmp dir, which the artifact doesn't exist anymore.

Now I'm using my own method to combine the "clone_repo_to" property and the "repo_name", which I got from the static method Repository._get_repo_name_from_url.

Propose solution:

So I thought it would be nice to have a method to get that path straight from a Repository instance.

Let me know if this makes sense. Happy to work on it.

hatrg commented

I should mention that I'm using version 2.1 at the time this issue created.

Hey!
While inside a commit, there is a "project_path" property that returns the absolute path.

for commit in Repository(..).traverse_commits():
     commit.project_path

Is this what you mean?

hatrg commented

yeah I'm aware of that, and it makes perfect sense, I seem to forget that an instance of Repository can host multiple repos.

I'll close this, thanks a lot!