本文整理汇总了TypeScript中nodegit.Branch类的典型用法代码示例。如果您正苦于以下问题:TypeScript Branch类的具体用法?TypeScript Branch怎么用?TypeScript Branch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Branch类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: rateLimit
promises.push((async () => {
const dir = path.join('repos', ghRepo.name);
let repo: nodegit.Repository;
if (existsSync(dir)) {
repo = await nodegit.Repository.open(dir);
} else {
await rateLimit(100);
repo = await nodegit.Clone.clone(ghRepo.clone_url, dir, undefined);
}
let skipThisElement = false;
if (opts.branchToFix !== 'master') {
let ref = undefined;
try {
ref = await repo.getBranch(`refs/remotes/origin/${opts.branchToFix}`);
} catch (_) {
skipThisElement = true;
}
if (ref) {
const commit = await repo.getReferenceCommit(ref);
const branch =
await nodegit.Branch.create(repo, opts.branchToFix, commit, 1);
await repo.checkoutBranch(branch);
}
}
if (skipThisElement) {
return undefined;
}
return new ElementRepo({repo, dir, ghRepo, analyzer: null});
})());
示例2: checkoutNewBranch
/**
* Creates a branch with the given name on the given repo.
*
* returns a promise of the nodegit Branch object for the new branch.
*/
async function checkoutNewBranch(
repo: nodegit.Repository, branchName: string): Promise<void> {
const commit = await repo.getHeadCommit();
const branch =
await nodegit.Branch.create(repo, branchName, commit, false);
return repo.checkoutBranch(branch);
}
示例3:
let result = Git.Attr.addMacro(repo, "name", "values");
Git.Attr.cacheFlush(repo);
Git.Attr.get(repo, 1, "path", "name").then((string) => {
// Use string
});
const array = Git.Attr.getMany(repo, 1, "path", 1, "names");
result = Git.Attr.value("attr");
const blameOptions = new Git.BlameOptions();
Git.Branch.lookup(repo, "branch_name", Git.Branch.BRANCH.LOCAL).then((reference) => {
// Use reference
});
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);
});
const signature = Git.Signature.now("name", "email");
signature.name();
signature.email();
signature.when();
repo.createBlobFromBuffer(Buffer.from("test")).then((oid: Git.Oid) => oid.cpy());
示例4:
.then(branch => Git.Branch.upstream(branch))
示例5:
.then(function(commit) {
console.log("3.0");
return Git.Branch.create(repos, bn, commit, 0);
})