Skip to content

Wrong import of GitError #46

@UweSchwaeke

Description

@UweSchwaeke

in file crt/src/crt/cmds/release.py

from git import GitError

This imports git.exc.GitError (gitpython's base exception), NOT
crt.crtlib.git_utils.GitError (the project's CRTError subclass). The
project's git utility functions raise crt.crtlib.git_utils.GitError, so the
except GitError clauses actually catch gitpython's lower-level exceptions
rather than (or in addition to) the intended ones. They do happen to also catch
the crtlib GitError only because gitpython's GitError is broader.

Pre-existing issue, but interacts with new code: _prepare_release_repo
(line ~79) and _prepare_release_branches (line ~120) both use except GitError. The crtlib functions will raise crtlib's GitError, and these except
blocks catch gitpython's GitError instead. This works accidentally because
gitpython's GitError inherits from Exception, and the crtlib GitError also
inherits from Exception. But the catch is NOT type-correct -- it catches the
wrong type hierarchy.

Severity: Medium (works by accident; should import from crt.crtlib.git_utils)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions