diff options
author | Jason Chang <jasonnc@google.com> | 2023-08-17 11:36:41 -0700 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-08-21 16:52:48 +0000 |
commit | 5a3a5f7cec40c70d8c5ceb473f828e1149724962 (patch) | |
tree | ec64b0ed6afde9632ec93f4215ce5dfad54383f1 /project.py | |
parent | 11cb96030ed5a0c322b5262c10a6af1a70486981 (diff) | |
download | git-repo-5a3a5f7cec40c70d8c5ceb473f828e1149724962.tar.gz |
upload: fix error handling
There was a bug in error handeling code that caused an uncaught
exception to be raised.
Bug: b/296316540
Change-Id: I49c72f29c00f26ba60de552f958bc6eddf841162
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/383254
Reviewed-by: Mike Frysinger <vapier@google.com>
Commit-Queue: Jason Chang <jasonnc@google.com>
Tested-by: Jason Chang <jasonnc@google.com>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -1116,7 +1116,8 @@ class Project(object): | |||
1116 | if not re.match(r"^.+[+-][0-9]+$", label): | 1116 | if not re.match(r"^.+[+-][0-9]+$", label): |
1117 | raise UploadError( | 1117 | raise UploadError( |
1118 | f'invalid label syntax "{label}": labels use forms like ' | 1118 | f'invalid label syntax "{label}": labels use forms like ' |
1119 | "CodeReview+1 or Verified-1" | 1119 | "CodeReview+1 or Verified-1", |
1120 | project=self.name, | ||
1120 | ) | 1121 | ) |
1121 | 1122 | ||
1122 | if dest_branch is None: | 1123 | if dest_branch is None: |
@@ -1132,7 +1133,7 @@ class Project(object): | |||
1132 | 1133 | ||
1133 | url = branch.remote.ReviewUrl(self.UserEmail, validate_certs) | 1134 | url = branch.remote.ReviewUrl(self.UserEmail, validate_certs) |
1134 | if url is None: | 1135 | if url is None: |
1135 | raise UploadError("review not configured") | 1136 | raise UploadError("review not configured", project=self.name) |
1136 | cmd = ["push"] | 1137 | cmd = ["push"] |
1137 | if dryrun: | 1138 | if dryrun: |
1138 | cmd.append("-n") | 1139 | cmd.append("-n") |
@@ -1177,8 +1178,9 @@ class Project(object): | |||
1177 | ref_spec = ref_spec + "%" + ",".join(opts) | 1178 | ref_spec = ref_spec + "%" + ",".join(opts) |
1178 | cmd.append(ref_spec) | 1179 | cmd.append(ref_spec) |
1179 | 1180 | ||
1180 | if GitCommand(self, cmd, bare=True).Wait() != 0: | 1181 | GitCommand( |
1181 | raise UploadError("Upload failed") | 1182 | self, cmd, bare=True, capture_stderr=True, verify_command=True |
1183 | ).Wait() | ||
1182 | 1184 | ||
1183 | if not dryrun: | 1185 | if not dryrun: |
1184 | msg = "posted to %s for %s" % (branch.remote.review, dest_branch) | 1186 | msg = "posted to %s for %s" % (branch.remote.review, dest_branch) |