pydriller icon indicating copy to clipboard operation
pydriller copied to clipboard

ENH: Print more informative error message instead of `Cmd('git') failed due to: exit code(128)`

Open corneliusroemer opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe. I love pydriller. Using it to step through all versions of a file in a large repo: https://github.com/corneliusroemer/pango-designation-dates

Things worked fine locally, but when I went to setup a Github action I got a cryptic error with a not so helpful error message:

  File "/opt/hostedtoolcache/Python/3.10.7/x64/lib/python3.10/site-packages/git/cmd.py", line 502, in wait
    raise GitCommandError(remove_password_if_present(self.args), status, errstr)

git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git diff-tree 5eab208aa8609fcf7c575757d5593614b5997 a4a94163d2e9f9ce7791f8bf79d626b64f69 -r --abbrev --full-index -M -p --no-color

When I ran that command git diff-tree ... locally, everything was fine.

I needed to ssh into the Github action using tmate to run it locally, and that helped, I got an error that said bad commit - because I had shallow-cloned the repo using the default settings of actions/checkout@v3.

I was wondering why the traceback pydriller provides doesn't state that more helpful error message. Would it be possible to include that somehow?

Describe the solution you'd like Provide more useful and informative error information other than Cmd('git') failed due to: exit code(128).

Additional context Here's the full traceback:

File "/home/runner/work/pango-designation-dates/pango-designation-dates/get_designation_date.py", line 54, in main
    for file in commit.modified_files:

  File "/opt/hostedtoolcache/Python/3.10.7/x64/lib/python3.10/site-packages/pydriller/domain/commit.py", line 667, in modified_files
    self._modified_files = self._get_modified_files()

  File "/opt/hostedtoolcache/Python/3.10.7/x64/lib/python3.10/site-packages/pydriller/domain/commit.py", line 682, in _get_modified_files
    diff_index = self._c_object.parents[0].diff(

  File "/opt/hostedtoolcache/Python/3.10.7/x64/lib/python3.10/site-packages/git/diff.py", line 175, in diff
    index = diff_method(self.repo, proc)

  File "/opt/hostedtoolcache/Python/3.10.7/x64/lib/python3.10/site-packages/git/diff.py", line 454, in _index_from_patch_format
    handle_process_output(proc, text_list.append, None, finalize_process, decode_streams=False)

  File "/opt/hostedtoolcache/Python/3.10.7/x64/lib/python3.10/site-packages/git/cmd.py", line 176, in handle_process_output
    return finalizer(process)

  File "/opt/hostedtoolcache/Python/3.10.7/x64/lib/python3.10/site-packages/git/util.py", line 386, in finalize_process
    proc.wait(**kwargs)

  File "/opt/hostedtoolcache/Python/3.10.7/x64/lib/python3.10/site-packages/git/cmd.py", line 502, in wait
    raise GitCommandError(remove_password_if_present(self.args), status, errstr)

git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git diff-tree 5eab208aa8609fcf7c575757d5593614b5997 a4a94163d2e9f9ce7791f8bf79d626b64f69 -r --abbrev --full-index -M -p --no-color

Thanks for your work developing this great tool!

corneliusroemer avatar Oct 01 '22 12:10 corneliusroemer

Hi @corneliusroemer! Thanks for your words 😄

Not sure Gitpython provides anything more than Cmd('git') failed due to. But sure, if anyone in the community wants to investigate this please do 👍

ishepard avatar Oct 01 '22 17:10 ishepard

Thanks, so this is an upstream issue then? Just thought I start here 😅

corneliusroemer avatar Oct 01 '22 20:10 corneliusroemer

@corneliusroemer Hello, did you find any way to handle this issue till now? We met the same issue and the full traceback is almost the same. If you have any good idea, we can exchange and discuss. Thank you!

liuxin-James avatar Sep 25 '23 06:09 liuxin-James

@ishepard I met the same issue and the full traceback is almost the same. I did not find a good way to handle it, did you have any other good idea to get more informative error message in this case to help handle this issue?

liuxin-James avatar Sep 26 '23 01:09 liuxin-James