本文整理汇总了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]);
}
示例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); });
}
示例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);
});
示例4:
const getSignature = () => nodegit.Signature.now(
'Polymer Format Bot', 'format-bot@polymer-project.org');