Skip to content

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

@corneliusroemer

Description

@corneliusroemer

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    PR welcomeIssue is confirmed, but not fixed yetenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions