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

lerna import fails "Command failed: git am -3 --keep-non-patch" #2351

Closed
doums opened this issue Nov 18, 2019 · 4 comments · Fixed by #2588
Closed

lerna import fails "Command failed: git am -3 --keep-non-patch" #2351

doums opened this issue Nov 18, 2019 · 4 comments · Fixed by #2588

Comments

@doums
Copy link

doums commented Nov 18, 2019

Hi,

From my lerna monorepo I'm trying to import an external project.

Expected Behavior

lerna import ../external_repo --flatten should succeed

Current Behavior

lerna import ../external_repo --flatten fails with the following error message:

~/D/o/lerna ❯❯❯ lerna import ../external_repo --flatten
info cli using local version of lerna
lerna notice cli v3.18.3
lerna info versioning independent
lerna info About to import 615 commits from ../external_repo into packages/external_repo
? Are you sure you want to import these commits onto the current branch? Yes
lerna info 1fa128eb 
...
lerna info 20db6d0e 
lerna ERR! import Rolling back to previous HEAD (commit 412f88d993e98e51b3242c61ff899ece8dbe341e)
lerna ERR! EIMPORT Failed to apply commit 20db6d0e.
lerna ERR! EIMPORT Command failed: git am -3 --keep-non-patch
lerna ERR! EIMPORT The current patch is empty.
lerna ERR! EIMPORT Quand vous avez résolu ce problème, lancez "git am --continue".
lerna ERR! EIMPORT Si vous préférez plutôt sauter ce patch, lancez "git am --skip".
lerna ERR! EIMPORT Pour restaurer la branche originale et arrêter de patcher, lancez "git am --abort".
lerna ERR! EIMPORT 
lerna ERR! EIMPORT 
lerna ERR! EIMPORT You may try again with --flatten to import flat history.

We can see lerna fails to apply the commit 20db6d0e.
Here you can see the commit's info from the external repo

~/D/o/external_repo ❯❯❯ git show 20db6d0e
commit 20db6d0e6af4c8e59b380d1d9fac4054108517a5
Merge: 9ba5c7e6 e146b579
Author: xxxx <xxxx@gmail.com>
Date:   Tue Sep 17 16:46:18 2019 +0200

    Merge pull request #300 from xxxx/fix/xx
    
    Fix error value of null

and

~/D/o/external_repo ❯❯❯ git show 9ba5c7e6
commit 9ba5c7e6c4f06a2e6613c4ff611d180efa92cdb2
Merge: 933211d9 b889fafb
Author: xxx <xxx@gmail.com>
Date:   Tue Sep 17 14:17:23 2019 +0200

    Merge pull request #301 from xxx/hotFix/owp
    
    Fix Logarithm value CummulatedPerf and yesterday of RefPortfolio

~/D/o/external_repo ❯❯❯ git show e146b579
commit e146b579a55b5404658f55c74784a63e8b962396
Author: xxx <xxx@gmail.com>
Date:   Wed Sep 11 18:09:51 2019 +0200

    Fix error value of null

diff --git xxxx.js
index a212efea..2340eee0 100644
--- xxxx.js
+++ xxxx.js
...some diff details in code

Possible Solution

I'm not sure what cause this problem and I have no idea how to make the import succeed.

lerna.json

{                         
  "packages": [
    "packages/*"
  ],
  "npmClient": "yarn",
  "useWorkspaces": true,
  "version": "independent"
}

lerna-debug.log

the error does not produces logs

Your Environment

Executable Version
lerna --version 3.18.3
npm --version 6.13.0
yarn --version 1.19.1
node --version v10.17.0
git 2.24.0
OS Version
Arch Linux 5.3.11-arch1-1
@mzuccaroli
Copy link

same issue here

@mzuccaroli
Copy link

If it can be useful I have bypassed the problem: my "breaking" commit was very small, so i perform a git -rebase -i , delete the commit, and manually resolve the conflicts, after that the lerna import command was able to complete the import

@nkalinov
Copy link

+1 still trying to figure out what is causing this.
FWIW my error is:

lerna ERR! EIMPORT Command failed: git am -3 --keep-non-patch
lerna ERR! EIMPORT error: sha1 information is lacking or useless (packages/ui/ui/.babelrc).
lerna ERR! EIMPORT error: could not build fake ancestor

@beeirl
Copy link

beeirl commented May 21, 2020

For anyone who's facing the problem @doums described.
I got it working by removing empty git commits via

git filter-branch --commit-filter 'if [ z$1 = z`git rev-parse $3^{tree}` ]; then skip_commit "$@"; else git commit-tree "$@"; fi' "$@"

Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants