Skip to content

Commit d1ca769

Browse files
[FIX] Propagate exception when git url does not match
* Don't drop exception silently (and continue) when it occurs in a forked off thread * Raise, not exit on unknown git branch * Raise when git url does not match
1 parent 1ff9a84 commit d1ca769

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/mr/developer/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ def worker(working_copies, the_queue):
168168
return
169169
try:
170170
output = action(**kwargs)
171-
except WCError:
171+
except WCError as e:
172+
threading.current_thread().exc = e
172173
output_lock.acquire()
173174
for lvl, msg in wc._output:
174175
lvl(msg)
@@ -259,6 +260,8 @@ def _cleanup():
259260
thread.start()
260261
threads.append(thread)
261262
for thread in threads:
263+
if hasattr(thread, "exc"):
264+
raise thread.exc
262265
thread.join()
263266
if sys.version_info < (2, 6):
264267
subprocess._cleanup = _old_subprocess_cleanup

src/mr/developer/git.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ def git_switch_branch(self, stdout_in, stderr_in, accept_missing=False):
199199
return (stdout_in + stdout,
200200
stderr_in + stderr)
201201
else:
202-
self.output((logger.error, "No such branch %r", branch))
203-
sys.exit(1)
202+
raise GitError("No such branch %r" % branch)
204203
# runs the checkout with predetermined arguments
205204
cmd = self.run_git(argv, cwd=path)
206205
stdout, stderr = cmd.communicate()
@@ -288,7 +287,10 @@ def matches(self):
288287
def update(self, **kwargs):
289288
name = self.source['name']
290289
if not self.matches():
291-
self.output((logger.warning, "Can't update package '%s' because its URL doesn't match." % name))
290+
message = "Can't update package '%s' because its URL doesn't match." % name
291+
if kwargs.get("force"):
292+
raise GitError(message)
293+
self.output((logger.warning, message))
292294
if self.status() != 'clean' and not kwargs.get('force', False):
293295
raise GitError("Can't update package '%s' because it's dirty." % name)
294296
return self.git_update(**kwargs)

0 commit comments

Comments
 (0)