-
So from what I can tell there is no way to get the full abspath (aka, like what you would get from git diff-tree --name-only -r for modified files. This is not great in the sense that when gathering metadata on a project, you often have name collisions (aka, Makefile can exist in two directories). From what I can tell tell, the ModifiedFile object gets initialized from the GitPython object's new path, and getting abspath would not be trivial. :( Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Hey Dave!
and I change both files, I will have:
so you shouldn't have conflicts, right? |
Beta Was this translation helpful? Give feedback.
-
This would be the ideal, but actually what you get is just:
file1.txt and file1.txt :)
In domain/commit.py:
self._new_path = Path(new_path) if new_path is not None else None
From parse_diff:
def _parse_diff(self, diff_index) -> List[ModifiedFile]:
modified_files_list = []
for diff in diff_index:
old_path = diff.a_path
new_path = diff.b_path
Which I believe comes from:
https://github.com/gitpython-developers/GitPython/blob/main/git/diff.py
Which if I understand correctly, is the final blob's name (aka, not a
Path.join(tree[0:]) as you would want for abspath?
…-dave
On Wed, Jun 23, 2021 at 9:33 AM Davide Spadini ***@***.***> wrote:
Hey Dave!
Mmm the names should be different, right?
I mean, if I have:
- repo/
- file1.txt
- dir1/
- file1.txt
and I change both files, I will have:
file1.txt
dir1/file1.txt
so you shouldn't have conflicts, right?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#188 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE25MYSAK7GPOOPTZ2IW66TTUHPEHANCNFSM47FULRNQ>
.
|
Beta Was this translation helpful? Give feedback.
-
Mmmmm no then there is something wrong :) you get the full path.
and you will see:
|
Beta Was this translation helpful? Give feedback.
-
Is modification.filename different from modification.new_path ? Perhaps
that is what I am failing at?
* small snippet of my code here *
for modification in commitfiles:
print('Author {} modified {} in commit {}'.format(
commit.author.name, modification.filename, commit.hash))
*Thanks for the responses btw.
…On Wed, Jun 23, 2021 at 11:20 AM Davide Spadini ***@***.***> wrote:
Mmmmm no then there is something wrong :) you get the full path.
Try to run:
from pydriller import Repository
for commit in Repository("test-repos/complex_repo").traverse_commits():
for mod in commit.modified_files:
print(mod.new_path)
and you will see:
Matricula.java
Aluno.java
Matricula.java
Secao.java
Secao.java
None
Matricula.java
Matricula.java
Matricula.java
Matricula.javax
Secao.javax
pasta/Capitulo.java. <-------- as you can see, there is the full path
.DS_Store
Arquivo.java
Arquivo.java
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#188 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE25MYRJPFQ7REKVQK57LHDTUH3UFANCNFSM47FULRNQ>
.
|
Beta Was this translation helpful? Give feedback.
-
Oh mistery solved :)
What you want is the path (like in git, you have 2 paths, old and new, before and after the change, so you need to check both). No worries, glad I could help! |
Beta Was this translation helpful? Give feedback.
Oh mistery solved :)
See here: https://pydriller.readthedocs.io/en/latest/modifiedfile.html
What you want is the path (like in git, you have 2 paths, old and new, before and after the change, so you need to check both).
No worries, glad I could help!