當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Repository.init方法代碼示例

本文整理匯總了TypeScript中@elastic/nodegit.Repository.init方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Repository.init方法的具體用法?TypeScript Repository.init怎麽用?TypeScript Repository.init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@elastic/nodegit.Repository的用法示例。


在下文中一共展示了Repository.init方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: prepareProject

  async function prepareProject(repoPath: string) {
    mkdirp.sync(repoPath);
    const repo = await Git.Repository.init(repoPath, 0);
    const content = '';
    fs.writeFileSync(path.join(repo.workdir(), '1'), content, 'utf8');
    const subFolder = 'src';
    fs.mkdirSync(path.join(repo.workdir(), subFolder));
    fs.writeFileSync(path.join(repo.workdir(), 'src/2'), content, 'utf8');
    fs.writeFileSync(path.join(repo.workdir(), 'src/3'), content, 'utf8');

    const index = await repo.refreshIndex();
    await index.addByPath('1');
    await index.addByPath('src/2');
    await index.addByPath('src/3');
    index.write();
    const treeId = await index.writeTree();
    const committer = Git.Signature.create('tester', 'test@test.com', Date.now() / 1000, 60);
    const commit = await repo.createCommit(
      'HEAD',
      committer,
      committer,
      'commit for test',
      treeId,
      []
    );
    // eslint-disable-next-line no-console
    console.log(`created commit ${commit.tostrS()}`);
    return repo;
  }
開發者ID:elastic,項目名稱:kibana,代碼行數:29,代碼來源:git_operations.ts

示例2: prepareProject

  async function prepareProject(repoPath: string) {
    mkdirp.sync(repoPath);
    const repo = await Git.Repository.init(repoPath, 0);
    const content = 'console.log("test")';
    const subFolder = 'src';
    fs.mkdirSync(path.join(repo.workdir(), subFolder));
    fs.writeFileSync(path.join(repo.workdir(), 'src/app.ts'), content, 'utf8');

    const index = await repo.refreshIndex();
    await index.addByPath('src/app.ts');
    index.write();
    const treeId = await index.writeTree();
    const committer = Git.Signature.create('tester', 'test@test.com', Date.now() / 1000, 60);
    const commit = await repo.createCommit(
      'HEAD',
      committer,
      committer,
      'commit for test',
      treeId,
      []
    );
    return { repo, commit };
  }
開發者ID:elastic,項目名稱:kibana,代碼行數:23,代碼來源:workspace_handler.ts

示例3: prepareProject

  async function prepareProject(repoPath: string) {
    mkdirp.sync(repoPath);
    const repo = await Git.Repository.init(repoPath, 0);
    const helloContent = "console.log('hello world');";
    fs.writeFileSync(path.join(repo.workdir(), filename), helloContent, 'utf8');

    let index = await repo.refreshIndex();
    await index.addByPath(filename);
    index.write();
    const treeId = await index.writeTree();
    const committer = Git.Signature.create('tester', 'test@test.com', Date.now() / 1000, 60);
    const commit = await repo.createCommit(
      'HEAD',
      committer,
      committer,
      'commit for test',
      treeId,
      []
    );
    firstCommitSha = commit.tostrS();
    fs.writeFileSync(path.join(repo.workdir(), 'package.json'), packagejson, 'utf8');
    index = await repo.refreshIndex();
    await index.addByPath('package.json');
    index.write();
    const treeId2 = await index.writeTree();
    const commit2 = await repo.createCommit(
      'HEAD',
      committer,
      committer,
      'commit2 for test',
      treeId2,
      [commit]
    );
    secondCommitSha = commit2.tostrS();

    return repo;
  }
開發者ID:elastic,項目名稱:kibana,代碼行數:37,代碼來源:lsp_service.ts


注:本文中的@elastic/nodegit.Repository.init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。