本文整理匯總了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');