From 8141fa4487ca390b0b0812bdc0d14c0932ff384c Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Sat, 1 Aug 2026 14:16:44 -0700 Subject: [PATCH] Restore repo-tracked files after copying test binaries The install/copy-binaries script rm -rf's and re-copies the installed extension's bin, debugAdapters, and LLVM folders. A few files under bin are checked into the repo (bin/cpp.hint and bin/messages/**/messages.json); the copy overwrote them with the installed extension's versions (differing line endings and/or content), leaving spurious local modifications that had to be reverted by hand. Restore any tracked files the copy changed so only the untracked binaries remain, and gitignore the generated bin/binaryVersion.json marker. --- Extension/.gitignore | 1 + Extension/.scripts/copyExtensionBinaries.ts | 31 ++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Extension/.gitignore b/Extension/.gitignore index a2f6b3612..bc791bd25 100644 --- a/Extension/.gitignore +++ b/Extension/.gitignore @@ -10,6 +10,7 @@ server debugAdapters LLVM bin/assert_dialog.sh +bin/binaryVersion.json bin/cpptools* bin/edge_cli bin/isense_driver diff --git a/Extension/.scripts/copyExtensionBinaries.ts b/Extension/.scripts/copyExtensionBinaries.ts index 23c9b13e0..107f3a74c 100644 --- a/Extension/.scripts/copyExtensionBinaries.ts +++ b/Extension/.scripts/copyExtensionBinaries.ts @@ -7,7 +7,7 @@ import { cp, readdir, rm, stat } from 'node:fs/promises'; import { homedir } from 'node:os'; import { basename, join } from 'node:path'; import { verbose } from '../src/Utility/Text/streams'; -import { $args, $root, green, heading, note } from './common'; +import { $args, $root, Git, green, heading, note, warn } from './common'; const extensionPrefix = 'ms-vscode.cpptools-'; const foldersToCopy = ['bin', 'debugAdapters', 'LLVM'] as const; @@ -125,6 +125,33 @@ async function findLatestInstalledExtension(providedPath?: string): Promise { + const modified = await Git('ls-files', '--modified', '--', ...foldersToCopy); + if (modified.code) { + warn(`Unable to determine which tracked files to restore: ${modified.error.all().join('\n')}`); + return; + } + + const files = modified.stdio.all().map(line => line.trim()).filter(line => line.length > 0); + if (!files.length) { + return; + } + + const restored = await Git('checkout', '--', ...files); + if (restored.code) { + warn(`Unable to restore tracked files after copy: ${restored.error.all().join('\n')}`); + return; + } + + note(`Restored ${files.length} tracked ${files.length === 1 ? 'file' : 'files'} overwritten by the copy.`); +} + export async function main(sourcePath = $args[0]): Promise { console.log(heading('Copy installed extension binaries')); @@ -142,6 +169,8 @@ export async function main(sourcePath = $args[0]): Promise { note(`Copied installed binaries into ${$root}`); + await restoreTrackedFiles(); + const installedVersion = tryParseVersion(basename(installedExtensionPath)); return installedVersion?.join('.'); }