Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(version): Add friendly error message when remote branch is missing #1741

Conversation

danielcondemarin
Copy link
Contributor

Fix for a cryptic error that lerna version currently throws when the branch is missing in the remote.

Description

If the current branch doesn't exist in the remote, lerna throws the following error:

lerna ERR! Error: Command failed: git rev-list --left-right --count origin/xyz...xyz
lerna ERR! fatal: ambiguous argument 'origin/xyz...xyz': unknown revision or path not in the working tree.
lerna ERR! Use '--' to separate paths from revisions, like this:
lerna ERR! 'git <command> [<revision>...] -- [<file>...]'
...

This PR adds a check when lerna version is ran, so that it is verified first that the remote branch exists. If it doesn't exist, a new ValidationError (EMISSREMOTEBRANCH) will be thrown, i.e.:
Branch 'foo' doesn't exist in remote 'origin'. If this is a new branch, please make sure you push it to the remote first.

Motivation and Context

The existing error thrown when the remote branch doesn't exist is misleading and doesn't make sense in the context of lerna version.

How Has This Been Tested?

Added unit tests and integration tests. I've also tested it manually, environment:
MacBook Pro macOS High Sierra
node v9.8.0
git 2.15.2

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Member

@evocateur evocateur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@lock
Copy link

lock bot commented Dec 27, 2018

This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants