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


TypeScript nodegit.Signature類代碼示例

本文整理匯總了TypeScript中nodegit.Signature的典型用法代碼示例。如果您正苦於以下問題:TypeScript Signature類的具體用法?TypeScript Signature怎麽用?TypeScript Signature使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Signature類的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類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。