Fix #78: clear error when a configured branch does not exist#92
Merged
Conversation
- git_checkout detects 'remote branch not found' clone failures and raises a message naming the package, branch and URL, pointing at the mx.ini setting. - git_switch_branch and git_merge_rbranch raise the same clear GitError instead of logging a terse 'No such branch' and calling sys.exit(1), so the update path behaves consistently with checkout. - The worker reports expected WCErrors as a plain error message and keeps the full traceback at debug level only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #78.
Problem
When a
branchconfigured inmx.inidoes not exist on the remote, mxdev reported it poorly:GitError("git cloning of '<name>' failed.\n<raw git stderr>"), with the real reason (fatal: Remote branch X not found in upstream origin) buried in stderr, plusworkerlogged expected operationalWCErrors withlogger.exception).No such branch Xfollowed by a hardsys.exit(1).(Root-cause analysis: see issue comment.)
Approach
A — clear, actionable message.
git_checkoutdetects the "remote branch not found" clone failure and raises a message naming the package, branch and URL, pointing at themx.inisetting:B — no scary traceback for expected errors. The
workerlogsWCErrors as a plainlogger.error(<message>); the full traceback drops tologger.debug(available when debugging, hidden in normal runs).Update path.
git_switch_branchand the defensive check ingit_merge_rbranchnow raise the same clearGitErrorinstead oflogger.error(...) + sys.exit(1), so the failure flows through normal error handling consistently with the clone path.Status
Draft contains the failing tests reproducing both the checkout and update cases. Fix follows next.
Test Plan
test_checkout_missing_branch_gives_clear_errortest_update_missing_branch_gives_clear_errortest_worker_with_error(asserts the real message, not the generic one)