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


TypeScript Signature.now方法代码示例

本文整理汇总了TypeScript中nodegit.Signature.now方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Signature.now方法的具体用法?TypeScript Signature.now怎么用?TypeScript Signature.now使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nodegit.Signature的用法示例。


在下文中一共展示了Signature.now方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: addAllAndCommit

export async function addAllAndCommit(path: string,
                                      user: string,
                                      commitMessage: string,
                                      initial: boolean): Promise<void> {
  Log.info(`git commit -a -m "${commitMessage}"`);

  let repo: NodeGitRepository = await nodegit.Repository.open(path);
  let index = await repo.openIndex();
  await index.addAll();
  await index.write();
  let oid = await index.writeTree();

  var author = nodegit.Signature.now(user, user);
  var committer = nodegit.Signature.now(user, user);

  if (initial)
    return await repo.createCommit(HEAD, author, committer, commitMessage, oid, []);

  let head = await nodegit.Reference.nameToId(repo, HEAD);
  let parent = await repo.getCommit(head);

  return await repo.createCommit(HEAD, author, committer, commitMessage, oid, [parent]);
}
开发者ID:NohSeho,项目名称:oh-my-github-1,代码行数:23,代码来源:nodegit_util.ts

示例2: stageCommand

export async function stageCommand(config: Config, args) {
  const logger = config.logger;
  const path = args["p"] || args["path"] || process.cwd();
  const workingDir = await searchForProjectDir(path);
  const projectName = await getProjectName(workingDir);

  const remoteUrl = await Git.Repository.open(workingDir).then(function(repository) {
    return repository.getRemote("origin").then(function(remote) {
      return remote.url();
    });
  });
  const serveUrl = "https://tbtimes.github.io/" + projectName + "/";

  let servePath = join(workingDir, config.caches.DEPLOY_DIR, projectName);
  const projectDirs = await glob(`*/`, {cwd: servePath});
  const servePathGit = servePath + "/.git/";

  if (existsSync(servePathGit)) {
    logger.info("Deleting existing .git directory.")
    rmrf.sync(servePathGit);
  }

  let repo, index, oid;
  const token = args["t"] || args["token"] || config.GH_TOKEN || process.env.GH_TOKEN;
  if (!token)
      logger.error(`Must specify a token to access github.`) && process.exit(1);
  const pushOpts = {
      callbacks: {
          credentials: function () {
              return Git.Cred.userpassPlaintextNew(token, "x-oauth-basic");
          }
      }
  };
  if (process.platform === "darwin") {
      pushOpts.callbacks.certificateCheck = function () { return 1; };
  }
  const signature = Git.Signature.now("newsroom-user", "ejmurra2@gmail.com");

  await Git.Repository.init(servePath, 0)
    .then(function(repository) {
      repo = repository;
      return repo.refreshIndex().then(function(indexResult) {
        index = indexResult;
        return index.addAll()
          .then(function() {
            return index.write();
          })
          .then(function() {
            return index.writeTree();
          });
      });
    })
    .then(function(oidResult) {
      oid = oidResult;
      return repo.createCommit("HEAD", signature, signature, "lede stage", oid);
    })
    .then(function(o) {
      return repo.createBranch("gh-pages", o);
    })
    .then(function() {
      return repo.checkoutBranch("gh-pages");
    })
    .then(function() {
      return Git.Remote.create(repo, "origin", remoteUrl).then(function(remote) {
        logger.info("Pushing to GitHub.");
        return remote.push("+refs/heads/gh-pages:refs/heads/gh-pages", pushOpts)
          .then(function() {
            return projectDirs.map(dir=> logger.info(dir.slice(0,-1) + " served at " + serveUrl + dir));
          })
        })
      }, function(err) { logger.error(err); });
}
开发者ID:tbtimes,项目名称:lede-cli,代码行数:72,代码来源:stage.ts

示例3:

repo.getCommit("0123456789abcdef0123456789abcdef").then((commit) => {
  const sig = Git.Signature.now('John Doe', 'jd@example.com');
  const newCommit: Promise<Git.Oid> = commit.amend('ref', sig, sig, 'utf8', 'message', tree);
});
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:4,代码来源:nodegit-tests.ts

示例4:

 const getSignature = () => nodegit.Signature.now(
     'Polymer Format Bot', 'format-bot@polymer-project.org');
开发者ID:BruceZu,项目名称:tedium,代码行数:2,代码来源:util.ts


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