Skip to content

Improve "import" edgecases + (i18n fixes + git tweaks) - #1059

Merged
evocateur merged 3 commits into
lerna:masterfrom
swernerx:improve-import-edge-cases
Oct 27, 2017
Merged

evocateur merged 3 commits into
lerna:masterfrom
swernerx:improve-import-edge-cases

Conversation

@swernerx

@swernerx swernerx commented Oct 8, 2017

Copy link
Copy Markdown
Contributor

Description

Originally this just contains the fixes for handling issues detecting in #1058

  • Outputting added for errors when something unintended happens during importing of projects.
  • Added new handling to automatically skip empty commits. These are an anti-pattern I figure, but I saw them accidentally in some of my own repositories. As git does not seem to have a useful parameter for its am command we have to skip the command when detecting the empty commits error (my approach analyzes the error message from git).
  • Disabling GPG signing of all "git commit" runs as this seems to break the system. Lerna should not rely on the user to disabling this behavior manually.
  • We have some tests which compare the exact output of some commands. As these commands might be executed under the local env variables of the user they might differ from our tested ones. I added cross-env and added a LC_ALL setting in front of the npm script to run jest to overcome this.

Motivation and Context

This fixes to import my projects from Edge Platform into a single repository.

Without the change on skipping empty commits it just failed. Without the logging change, it failed without any useful user-facing error.

How Has This Been Tested?

The test suite and linting pass without any errors.

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.

@natesilva

Copy link
Copy Markdown

Thanks @swernerx. I’m testing Lerna, importing a big legacy project, and your branch was a lifesaver. I hope this gets merged ASAP.

@evocateur evocateur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @swernerx!

Comment thread package.json
"integration": "jest --config test/config/integration.json",
"pretest": "npm run lint -- --cache",
"test": "jest",
"test": "cross-env LC_ALL=en-US jest",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this! I was hoping to get away from the brittle localized snapshots eventually, but this is a good addition regardless.

if (!err) {
this.logger.success("import", "finished");
} else {
this.logger.error("import", err);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I can't believe we forgot to log the error 😅

Comment thread src/GitUtilities.js
static commit(message, opts) {
log.silly("commit", message);
const args = ["commit"];
const args = ["commit", "--no-gpg-sign"];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm a little leery of adding this flag to all executions of git commit. I have no idea how common GPG signing of commits is, although I definitely appreciate your reasoning.

I'm okay with taking this now, but we'll have to note this very well in the changelog and be open to the possibility that we may need to revert it (or put it behind an option) in the future.

@evocateur
evocateur merged commit 2adab3c into lerna:master Oct 27, 2017
evocateur added a commit to mitchhentges/lerna that referenced this pull request Oct 27, 2017
* master:
  Generate root changelog in fixed mode (lerna#1078)
  Republish prereleased packages during subsequent non-prerelease publish (lerna#1077)
  fix: fail when --hoist and --yarn are used together (lerna#1063)
  Improve "import" edgecases + (i18n fixes + git tweaks) (lerna#1059)
  Warn about two or more packages having the same npm package.json name (lerna#1081)
@rgbkrk

rgbkrk commented Oct 28, 2017

Copy link
Copy Markdown

Thanks for doing this, it was super helpful to see the error I'm running into:

lerna info 8520709
lerna ERR! import Failed to apply commit 8520709.
lerna ERR! import Error: Command failed: git am -3
lerna ERR! import error: Failed to merge in the changes.
lerna ERR! import Applying: chore(RefactorContents): Cleanup ajax settings.
lerna ERR! import Using index info to reconstruct a base tree...
lerna ERR! import M	packages/rx-jupyter/test/contents-spec.js
lerna ERR! import Falling back to patching base and 3-way merge...
lerna ERR! import Auto-merging packages/rx-jupyter/test/contents-spec.js
lerna ERR! import CONFLICT (content): Merge conflict in packages/rx-jupyter/test/contents-spec.js
lerna ERR! import Patch failed at 0001 chore(RefactorContents): Cleanup ajax settings.
lerna ERR! import The copy of the patch that failed is found in: .git/rebase-apply/patch
lerna ERR! import When you have resolved this problem, run "git am --continue".
lerna ERR! import If you prefer to skip this patch, run "git am --skip" instead.
lerna ERR! import To restore the original branch and stop patching, run "git am --abort".
lerna ERR! import
lerna ERR! import Rolling back to previous HEAD (commit 78c3e73fc680daca40dfb47cb9fd407066413338).
lerna ERR! import You may try with --flatten to import flat history.
lerna ERR! execute callback with error

I'm probably just going to rebase the originating repo on a branch and then importing from a version lerna can work with.

@rgbkrk

rgbkrk commented Oct 28, 2017

Copy link
Copy Markdown

Here's what I did to "fix" these commits:

git rebase -i --root
# Find commit 8520709
# Switch from `pick` to `reword`
# Also do this with the following commit

annnnd somehow I was able to import it after doing this
¯\_(ツ)_/¯

@lock

lock Bot commented Dec 27, 2018

Copy link
Copy Markdown

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.

4 participants