Skip to content

feat: add script to migrate PRs from vscode-copilot-chat to vscode#308236

Merged
joaomoreno merged 3 commits intomainfrom
joao/yellow-wombat
Apr 7, 2026
Merged

feat: add script to migrate PRs from vscode-copilot-chat to vscode#308236
joaomoreno merged 3 commits intomainfrom
joao/yellow-wombat

Conversation

@joaomoreno
Copy link
Copy Markdown
Member

@joaomoreno joaomoreno commented Apr 7, 2026

Run this to migrate PRs from vscode-copilot-chat:

node build/copilot-migrate-pr.ts PR_NUMBER

Example:

node build/copilot-migrate-pr.ts 5039

Copilot AI review requested due to automatic review settings April 7, 2026 15:47
@joaomoreno joaomoreno self-assigned this Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Screenshot Changes

Base: 5c2fdfe6 Current: 1636e8d2

Changed (1)

editor/inlineCompletionsExtras/JumpToHint/Light
Before After
before after

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a standalone build-time utility script to help migrate pull requests from microsoft/vscode-copilot-chat into microsoft/vscode by rewriting diff paths under extensions/copilot/, applying the patch locally, and creating a new PR via the gh CLI.

Changes:

  • Introduces build/copilot-migrate-pr.ts, a CLI script that fetches PR metadata + diff from microsoft/vscode-copilot-chat.
  • Rewrites unified diff paths to live under extensions/copilot/ and applies via git apply --3way.
  • Pushes a migration branch and opens a PR in microsoft/vscode, with an option to close the source PR.
Show a summary per file
File Description
build/copilot-migrate-pr.ts New migration CLI: fetch PR diff/metadata, rewrite paths, apply patch, push branch, and create target PR.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 4

Comment on lines +251 to +262
// Ensure we're on a clean state based on main
git(['checkout', 'main'], repoRoot);
git(['pull', '--ff-only', 'origin', 'main'], repoRoot);

// Create and switch to the new branch
try {
git(['checkout', '-b', branchName], repoRoot);
} catch {
// Branch may already exist from a previous attempt
git(['checkout', branchName], repoRoot);
git(['reset', '--hard', 'main'], repoRoot);
}
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

createBranchAndApplyDiff performs checkout main, pull, and potentially reset --hard without first verifying the worktree is clean. If the user has local changes, this can fail mid-way (or discard work on an existing migration branch), and it also makes the script risky to run accidentally. Consider checking git status --porcelain up front (and aborting or prompting), and avoid hard-resetting an existing branch without an explicit confirmation.

Copilot uses AI. Check for mistakes.
} catch {
console.log('\nThe diff could not be applied cleanly.');
console.log('Resolve merge conflicts in your working tree, then continue.');
for (; ;) {
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

for (; ;) has extra spaces inside the parentheses and doesn’t match the repo’s usual formatting (e.g. for (;;)). This will likely be reformatted by the formatter/hygiene checks; consider updating it to the standard form.

Suggested change
for (; ;) {
for (;;) {

Copilot uses AI. Check for mistakes.
}
}
} finally {
fs.unlinkSync(tmpDiff);
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

fs.unlinkSync(tmpDiff) in the finally will throw if writeFileSync fails (or if the temp file is otherwise missing), which can mask the original error and leave the repo in a partially modified state. Consider guarding with an existence check or wrapping the unlink in its own try/catch.

Suggested change
fs.unlinkSync(tmpDiff);
try {
fs.unlinkSync(tmpDiff);
} catch (error: NodeJS.ErrnoException) {
if (error.code !== 'ENOENT') {
throw error;
}
}

Copilot uses AI. Check for mistakes.
Comment on lines +386 to +387
const branchName = await createBranchAndApplyDiff(prNumber, meta.title, rewrittenDiff, repoRoot);
shouldRestoreRef = true;
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

shouldRestoreRef is only set to true after createBranchAndApplyDiff completes. If that function throws after changing the current ref (e.g. failing on checkout main/pull), the finally block won’t restore originalRef. Consider setting shouldRestoreRef before calling into the code that mutates git state (or restoring whenever getCurrentRef(repoRoot) differs from originalRef).

Suggested change
const branchName = await createBranchAndApplyDiff(prNumber, meta.title, rewrittenDiff, repoRoot);
shouldRestoreRef = true;
shouldRestoreRef = true;
const branchName = await createBranchAndApplyDiff(prNumber, meta.title, rewrittenDiff, repoRoot);

Copilot uses AI. Check for mistakes.
…n script

Co-authored-by: Copilot <copilot@github.com>
… conflicts

Co-authored-by: Copilot <copilot@github.com>
@joaomoreno joaomoreno merged commit a6d1a79 into main Apr 7, 2026
21 of 23 checks passed
@joaomoreno joaomoreno deleted the joao/yellow-wombat branch April 7, 2026 16:33
@vs-code-engineering vs-code-engineering bot added this to the 1.116.0 milestone Apr 7, 2026
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 this pull request may close these issues.

3 participants