当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Repository.open方法代码示例

本文整理汇总了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);
开发者ID:elastic,项目名称:kibana,代码行数:27,代码来源:lsp_service.ts

示例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;
}
开发者ID:elastic,项目名称:kibana,代码行数:9,代码来源:git_operations.ts

示例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);
     }
   }
 }
开发者ID:elastic,项目名称:kibana,代码行数:43,代码来源:repository_service.ts

示例4: getHeadRevision

export async function getHeadRevision(path: string): Promise<string> {
  const repo = await Repository.open(path);
  const commit = await repo.getHeadCommit();
  return commit.sha();
}
开发者ID:elastic,项目名称:kibana,代码行数:5,代码来源:git_operations.ts

示例5:

 return checkExists<Repository>(() => Repository.open(repoDir), `repo ${uri} not found`);
开发者ID:elastic,项目名称:kibana,代码行数:1,代码来源:git_operations.ts


注:本文中的@elastic/nodegit.Repository.open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。