本文整理汇总了TypeScript中nodegit.Branch.create方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Branch.create方法的具体用法?TypeScript Branch.create怎么用?TypeScript Branch.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nodegit.Branch
的用法示例。
在下文中一共展示了Branch.create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:
.then(function(commit) {
console.log("3.0");
return Git.Branch.create(repos, bn, commit, 0);
})