mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-31 00:10:04 +08:00
Session window: apply patch to local
This commit is contained in:
@@ -1061,6 +1061,20 @@ export class CommandCenter {
|
||||
await repo.pull();
|
||||
}
|
||||
|
||||
@command('_git.applyPatch')
|
||||
async applyPatch(repositoryPath: string, patchContent: string): Promise<void> {
|
||||
const dotGit = await this.git.getRepositoryDotGit(repositoryPath);
|
||||
const repo = new GitRepository(this.git, repositoryPath, undefined, dotGit, this.logger);
|
||||
const patchPath = path.join(os.tmpdir(), `vscode-patch-${Date.now()}.patch`);
|
||||
const { promises: fsp } = await import('fs');
|
||||
try {
|
||||
await fsp.writeFile(patchPath, patchContent, 'utf8');
|
||||
await repo.apply(patchPath, { threeWay: true });
|
||||
} finally {
|
||||
await fsp.unlink(patchPath).catch(() => { });
|
||||
}
|
||||
}
|
||||
|
||||
@command('git.init')
|
||||
async init(skipFolderPrompt = false): Promise<void> {
|
||||
let repositoryPath: string | undefined = undefined;
|
||||
|
||||
Reference in New Issue
Block a user