Skip to content

Resilience if git command fails #15

Closed
@mwichmann

Description

@mwichmann

I'm working on an experimental setup (following on from the thread in #12), and have made some fumble-finger mistakes on the local repo (typo when changing the git remote from https to git@). So the first generated git command line fails with an exception (as it should), and then the rollback/cleanup fails too. Here's part of the trace:

    return subprocess.run(list(map(str, cmd)), **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', 'push', '-f', 'origin', 'mwichmann/stack/1:mwichmann/stack/1', 'mwichmann/stack/2:mwichmann/stack/2', 'mwichmann/stack/3:mwichmann/stack/3']' returned non-zero exit status 128.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mats/.pyenv/versions/venv-system312/bin/stack-pr", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/mats/.pyenv/versions/venv-system312/lib64/python3.12/site-packages/stack_pr/cli.py", line 1222, in main
    print_cmd_failure_details(exc)
  File "/home/mats/.pyenv/versions/venv-system312/lib64/python3.12/site-packages/stack_pr/cli.py", line 568, in print_cmd_failure_details
    cmd_stdout = exc.stdout.decode("utf-8").replace("\\n", "\n").replace("\\t", "\t")
                 ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'decode'

Seems like a check for None there might be in order.

I've got the setup working now so probably won't see this again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions