Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
corneliusroemer opened this issue Oct 1, 2022 · 4 comments
Labels
enhancement New feature or request PR welcome Issue is confirmed, but not fixed yet

Comments

@corneliusroemer
Copy link

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 corneliusroemer changed the title ENH: Print more informative error message when git fails ENH: Print more informative error message instead of Cmd('git') failed due to: exit code(128) Oct 1, 2022
@ishepard
Copy link
Owner

ishepard commented Oct 1, 2022

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 ishepard added enhancement New feature or request PR welcome Issue is confirmed, but not fixed yet labels Oct 1, 2022
@corneliusroemer
Copy link
Author

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

@liuxin-James
Copy link

@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
Copy link

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PR welcome Issue is confirmed, but not fixed yet
Projects
None yet
Development

No branches or pull requests

3 participants