Skip to content

"Exception Cmd('git') failed due to:" - not trigegring try:except #1583

@rusnackor

Description

@rusnackor

Hello guys.

I am preparing scrip that is meant to pull/checkout more repositories in different directories.
However, soemtimes can happen this:

Exception Cmd('git') failed due to: exit code(1)
  cmdline: git pull -v origin
  stderr: 'error: Your local changes to the following files would be overwritten by merge:
        common_logic.py
        git_jobs.py
        svn_jobs.py
        test_updating.py
        updater.py
        updater_core.py
        updating_conf.py
        updating_consts.py
Please commit your changes or stash them before you merge.
Aborting'

But when I try to put my code into try:except block, like this:

import git

try:
    repo = git.Repo("/path/to/my/repo")
    o = repo.remotes.origin
    result = o.pull()
    for item in result:
        print("Item : {}".format(item))
except Exception as e:
    print("Exception {}".format(e))

Nothing changes, the script still throws exception and fails. Is it possible to cover this case, and make it not to crash?

PS: Is it possible to make it, that it does not ask me for credentials every time? (like put them inside of my code)

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