本文整理汇总了TypeScript中@elastic/nodegit.Repository.open方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Repository.open方法的具体用法?TypeScript Repository.open怎么用?TypeScript Repository.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@elastic/nodegit.Repository
的用法示例。
在下文中一共展示了Repository.open方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should update if a worktree is not the newest', async () => {
const lspservice = mockLspService();
try {
const revision = 'master';
// send a dummy request to open a workspace;
const response = await sendHoverRequest(lspservice, revision);
assert.ok(response);
const workspacePath = path.resolve(serverOptions.workspacePath, repoUri, revision);
const workspaceRepo = await Git.Repository.open(workspacePath);
// workspace is newest now
assert.strictEqual((await workspaceRepo.getHeadCommit()).sha(), secondCommitSha);
const firstCommit = await workspaceRepo.getCommit(firstCommitSha);
// reset workspace to an older one
// @ts-ignore
await Git.Reset.reset(workspaceRepo, firstCommit, Git.Reset.TYPE.HARD, {});
assert.strictEqual((await workspaceRepo.getHeadCommit()).sha(), firstCommitSha);
// send a request again;
await sendHoverRequest(lspservice, revision);
// workspace_handler should update workspace to the newest one
assert.strictEqual((await workspaceRepo.getHeadCommit()).sha(), secondCommitSha);
return;
} finally {
await lspservice.shutdown();
}
// @ts-ignore
}).timeout(10000);
示例2: getDefaultBranch
export async function getDefaultBranch(path: string): Promise<string> {
const repo = await Repository.open(path);
const ref = await repo.getReference(HEAD);
const name = ref.name();
if (name.startsWith(REFS_HEADS)) {
return name.substr(REFS_HEADS.length);
}
return name;
}
示例3: doUpdate
public async doUpdate(uri: string, key?: string): Promise<UpdateWorkerResult> {
const localPath = RepositoryUtils.repositoryLocalPath(this.repoVolPath, uri);
try {
const repo = await Git.Repository.open(localPath);
const cbs: RemoteCallbacks = {
credentials: this.credentialFunc(key),
};
// Ignore cert check on testing environment.
if (!this.enableGitCertCheck) {
cbs.certificateCheck = () => {
// Ignore cert check failures.
return 0;
};
}
await repo.fetchAll({
callbacks: cbs,
});
// TODO(mengwei): deal with the case when the default branch has changed.
const currentBranch = await repo.getCurrentBranch();
const currentBranchName = currentBranch.shorthand();
const originBranchName = `origin/${currentBranchName}`;
const originRef = await repo.getReference(originBranchName);
const headRef = await repo.getReference(currentBranchName);
if (!originRef.target().equal(headRef.target())) {
await headRef.setTarget(originRef.target(), 'update');
}
const headCommit = await repo.getHeadCommit();
this.log.debug(`Update repository to revision ${headCommit.sha()}`);
return {
uri,
branch: currentBranchName,
revision: headCommit.sha(),
};
} catch (error) {
if (error.message && error.message.startsWith(SSH_AUTH_ERROR.message)) {
throw SSH_AUTH_ERROR;
} else {
const msg = `update repository ${uri} error: ${error}`;
this.log.error(msg);
throw new Error(msg);
}
}
}
示例4: getHeadRevision
export async function getHeadRevision(path: string): Promise<string> {
const repo = await Repository.open(path);
const commit = await repo.getHeadCommit();
return commit.sha();
}
示例5:
return checkExists<Repository>(() => Repository.open(repoDir), `repo ${uri} not found`);