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(core): import should be rebasable #27940

Merged
merged 1 commit into from
Sep 17, 2024
Merged

Conversation

jaysoo
Copy link
Member

@jaysoo jaysoo commented Sep 16, 2024

When users run nx import and open a PR with the imported package, they should be able to use git rebase --rebase-merges to update their branch with latest main.

Why this matters

If the repo requires the PR to be updated with latest main before merge, the user must have a way to do this and avoid having to do the import process all over again.

Current Behavior

Rebase results in git error

Expected Behavior

Rebase works

Related Issue(s)

Fixes #

@jaysoo jaysoo requested a review from a team as a code owner September 16, 2024 18:07
Copy link

vercel bot commented Sep 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Sep 16, 2024 8:00pm

@jaysoo jaysoo force-pushed the fix/import-history branch 2 times, most recently from 1d523ba to 53e6358 Compare September 16, 2024 18:25
spinner.start(`Moving files and git history to ${destinationInSource}`);

// The result of filter-branch will contain only the files in the subdirectory at its root.
const files = await gitClient.getGitFiles('.');
Copy link
Member Author

Choose a reason for hiding this comment

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

NOTE: Moving files is no longer needed since both git filter-repo and git filter-branch can handle the move automatically, in a way that allows for rebase.

Copy link

🐳 We have a release for that!

This PR has a release associated with it. You can try it out using this command:

npx [email protected] my-workspace

Or just copy this version and use it in your own command:

0.0.0-pr-27940-4ec79a3
Release details 📑
Published version 0.0.0-pr-27940-4ec79a3
Triggered by @jaysoo
Branch fix/import-history
Commit 4ec79a3
Workflow run 10891526529

To request a new release for this pull request, mention someone from the Nx team or the @nrwl/nx-pipelines-reviewers.

// If source and destination are the same, then keep the file as is.
if (src === dest) continue;
const destFile = posix.join(dest, file.replace(srcRegex, ''));
const dir = posix.dirname(destFile);
Copy link
Member Author

Choose a reason for hiding this comment

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

NOTE: We have to use POSIX here, even on Windows machine.

`Do NOT squash and do NOT rebase these changes when merging these changes.`,
`If you would like to UNDO these changes, run "git reset HEAD~1 --hard"`,
`Do NOT squash these commits when merging these changes.`,
`If you rebase, make sure to use "--rebase-merges" to preserve merge commits.`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm guessing github does this under the hood? Hopefully it's the same for other VCS 🤔

@FrozenPandaz FrozenPandaz merged commit b921091 into master Sep 17, 2024
6 checks passed
@FrozenPandaz FrozenPandaz deleted the fix/import-history branch September 17, 2024 13:50
FrozenPandaz pushed a commit that referenced this pull request Sep 18, 2024
When users run `nx import` and open a PR with the imported package, they
should be able to use `git rebase --rebase-merges` to update their
branch with latest main.

## Why this matters

If the repo requires the PR to be updated with latest main before merge,
the user must have a way to do this and avoid having to do the import
process all over again.

<!-- 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
Rebase results in git error

## Expected Behavior
Rebase works

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #

(cherry picked from commit b921091)
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 25, 2024
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.

3 participants