This reverts commit f69fd3833e
.
This commit is contained in:
parent
eb17289602
commit
3c6bbc388e
|
@ -170,7 +170,7 @@
|
|||
"@elastic/javascript-typescript-langserver": "^0.1.23",
|
||||
"@elastic/lsp-extension": "^0.1.1",
|
||||
"@elastic/node-crypto": "0.1.2",
|
||||
"@elastic/nodegit": "0.25.0-alpha.14",
|
||||
"@elastic/nodegit": "0.25.0-alpha.12",
|
||||
"@elastic/numeral": "2.3.3",
|
||||
"@kbn/babel-preset": "1.0.0",
|
||||
"@kbn/elastic-idx": "1.0.0",
|
||||
|
|
|
@ -4,15 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import {
|
||||
Commit,
|
||||
Error as GitError,
|
||||
Repository,
|
||||
Reset,
|
||||
TreeEntry,
|
||||
// @ts-ignore
|
||||
Worktree,
|
||||
} from '@elastic/nodegit';
|
||||
import { Clone, Commit, Error as GitError, Repository, Reset, TreeEntry } from '@elastic/nodegit';
|
||||
import Boom from 'boom';
|
||||
import del from 'del';
|
||||
import fs from 'fs';
|
||||
|
@ -361,10 +353,6 @@ export class WorkspaceHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private workspaceWorktreeBranchName(repoName: string): string {
|
||||
return `workspace-${repoName}`;
|
||||
}
|
||||
|
||||
private async updateWorkspace(
|
||||
repositoryUri: string,
|
||||
revision: string,
|
||||
|
@ -374,13 +362,8 @@ export class WorkspaceHandler {
|
|||
const workspaceRepo = await Repository.open(workspaceDir);
|
||||
const workspaceHead = await workspaceRepo.getHeadCommit();
|
||||
if (workspaceHead.sha() !== targetCommit.sha()) {
|
||||
const commit = await workspaceRepo.getCommit(targetCommit.sha());
|
||||
this.log.info(`Checkout workspace ${workspaceDir} to ${targetCommit.sha()}`);
|
||||
// @ts-ignore
|
||||
const result = await Reset.reset(workspaceRepo, commit, Reset.TYPE.HARD, {});
|
||||
if (result !== undefined && result !== GitError.CODE.OK) {
|
||||
throw Boom.internal(`Reset workspace to commit ${targetCommit.sha()} failed.`);
|
||||
}
|
||||
this.log.info(`fetch workspace ${workspaceDir} from origin`);
|
||||
await workspaceRepo.fetch('origin');
|
||||
}
|
||||
return workspaceRepo;
|
||||
}
|
||||
|
@ -391,9 +374,8 @@ export class WorkspaceHandler {
|
|||
revision: string
|
||||
): Promise<Repository> {
|
||||
const workspaceDir = await this.revisionDir(repositoryUri, revision);
|
||||
this.log.info(`Create workspace ${workspaceDir} from url ${bareRepo.path()}`);
|
||||
this.log.info(`clone workspace ${workspaceDir} from url ${bareRepo.path()}`);
|
||||
const parentDir = path.dirname(workspaceDir);
|
||||
const mainBranchName = path.basename(workspaceDir);
|
||||
// on windows, git clone will failed if parent folder is not exists;
|
||||
await new Promise((resolve, reject) =>
|
||||
mkdirp(parentDir, err => {
|
||||
|
@ -404,15 +386,7 @@ export class WorkspaceHandler {
|
|||
}
|
||||
})
|
||||
);
|
||||
// Create the worktree and open it as Repository.
|
||||
const wt = await Worktree.add(
|
||||
bareRepo,
|
||||
this.workspaceWorktreeBranchName(mainBranchName),
|
||||
workspaceDir,
|
||||
{}
|
||||
);
|
||||
// @ts-ignore
|
||||
return await Repository.openFromWorktree(wt);
|
||||
return await Clone.clone(bareRepo.path(), workspaceDir);
|
||||
}
|
||||
|
||||
private setWorkspaceRevision(workspaceRepo: Repository, headCommit: Commit) {
|
||||
|
|
|
@ -1433,10 +1433,10 @@
|
|||
resolved "https://registry.yarnpkg.com/@elastic/node-crypto/-/node-crypto-0.1.2.tgz#c18ac282f635e88f041cc1555d806e492ca8f3b1"
|
||||
integrity sha1-wYrCgvY16I8EHMFVXYBuSSyo87E=
|
||||
|
||||
"@elastic/nodegit@0.25.0-alpha.14":
|
||||
version "0.25.0-alpha.14"
|
||||
resolved "https://registry.yarnpkg.com/@elastic/nodegit/-/nodegit-0.25.0-alpha.14.tgz#6ee459a3709064ded4e761ddae9415ccdeb13a49"
|
||||
integrity sha512-Z5UkqUiC/R4+bp+j/HNy/xgYhcVb2K32YGp8STQq+JV0VI/mbUsc0fWt15NV9oxXkfYIur2oT9jO9EtkDVIjBQ==
|
||||
"@elastic/nodegit@0.25.0-alpha.12":
|
||||
version "0.25.0-alpha.12"
|
||||
resolved "https://registry.yarnpkg.com/@elastic/nodegit/-/nodegit-0.25.0-alpha.12.tgz#6dffdbea640f8b297af75e96f84c802427dff7f7"
|
||||
integrity sha512-wKTji45igEw3VP2DmgLXpDX3n6WwOy0y4g/Xs385pymn9HWPVyg/UdWLJyXLrl0V//5EDSeqehMqOwTqAQ+qyA==
|
||||
dependencies:
|
||||
fs-extra "^7.0.0"
|
||||
json5 "^2.1.0"
|
||||
|
|
Loading…
Reference in a new issue