diff options
author | Josip Sokcevic <sokcevic@chromium.org> | 2024-03-14 23:50:33 +0000 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-03-15 19:26:10 +0000 |
commit | a3a73726129f7aa9cc12bbdc1f01700189936284 (patch) | |
tree | a1fe5d9c56397232a4be4df876e446906310254d /project.py | |
parent | fff1d2d74c2078b62cc9c2561330e41a842dc197 (diff) | |
download | git-repo-a3a73726129f7aa9cc12bbdc1f01700189936284.tar.gz |
main: Stringify project name in error_info
If a project can't be removed from checkout due to uncommitted changes
present, error.project is type of Project and not a string (as it is in
some cases). Project is not JSON serializable, resulting in exception
within exception handler:
TypeError: Object of type Project is not JSON serializable
This change casts project to string as a defensive mechanism. It also
passes project name instead of project object.
Change-Id: Ie7b782d73dc3647975755d5a3774d16ea6cd5348
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/413877
Tested-by: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -1813,11 +1813,11 @@ class Project: | |||
1813 | ) | 1813 | ) |
1814 | else: | 1814 | else: |
1815 | msg = ( | 1815 | msg = ( |
1816 | "error: %s: Cannot remove project: uncommitted" | 1816 | "error: %s: Cannot remove project: uncommitted " |
1817 | "changes are present.\n" % self.RelPath(local=False) | 1817 | "changes are present.\n" % self.RelPath(local=False) |
1818 | ) | 1818 | ) |
1819 | logger.error(msg) | 1819 | logger.error(msg) |
1820 | raise DeleteDirtyWorktreeError(msg, project=self) | 1820 | raise DeleteDirtyWorktreeError(msg, project=self.name) |
1821 | 1821 | ||
1822 | if verbose: | 1822 | if verbose: |
1823 | print(f"{self.RelPath(local=False)}: Deleting obsolete checkout.") | 1823 | print(f"{self.RelPath(local=False)}: Deleting obsolete checkout.") |