-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): filter branch in preparation for nx import (#27652)
This PR fixes an issue with `nx import` where multiple directories cannot be imported from the same repo. We now use `git filter-repo` (if installed) or `git filter-branch` (fallback) to prepare the repo for import so anything not in the subdirectory will be ignored (i.e. cleaner history). Note: `filter-repo` is much faster but requires the user to install it first via their package manager (e.g. `brew install git-filter-repo` or `apt install git-filter-repo`). We fallback to `git filter-branch` since it comes with git, but it is slower, so the process may take 10+ minutes on really large monorepos (e.g. next.js). Also: - Use `await` before returning a promise to Node can maintain correct stacktrace - Remove logic for `if (relativeSourceDir === '')` since using `filter-branch` moves all the files to the root (`.`) - Default destination project location to be the same as source (e.g. importing `packages/a` will go to `packages/a` unless user types in something else) - Add `--depth` option if users don't want to clone with full history (default is full history) - Fix issues with special characters causing `git ls-files` + `git mv` to since `mv` doesn't work with escaped names <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes # (cherry picked from commit ab408ab)
- Loading branch information
1 parent
d2b333f
commit 578d067
Showing
8 changed files
with
343 additions
and
268 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.