本文整理匯總了TypeScript中nodegit.Reference.nameToId方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Reference.nameToId方法的具體用法?TypeScript Reference.nameToId怎麽用?TypeScript Reference.nameToId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nodegit.Reference
的用法示例。
在下文中一共展示了Reference.nameToId方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: clearBranchElement
.then(function(branchList) {
let count = 0;
clearBranchElement();
for (let i = 0; i < branchList.length; i++) {
//console.log(branchList[i].name() + "!!!!");
let bp = branchList[i].name().split("/");
Git.Reference.nameToId(repository, branchList[i].name()).then(function(oid) {
// Use oid
//console.log(oid + " TTTTTTTT");
if (branchList[i].isRemote()) {
remoteName[bp[bp.length-1]] = oid;
} else {
branchCommit.push(branchList[i]);
console.log(bp[bp.length - 1] + "--------" + oid.tostrS());
if (oid.tostrS() in bname) {
bname[oid.tostrS()].push(branchList[i]);
} else {
bname[oid.tostrS()] = [branchList[i]];
}
}
}, function(err) {
console.log(err + "?????????");
});
if (branchList[i].isRemote()) {
if (localBranches.indexOf(bp[bp.length - 1]) < 0) {
displayBranch(bp[bp.length - 1], "branch-dropdown", "checkoutRemoteBranch(this)");
}
} else {
localBranches.push(bp[bp.length - 1]);
displayBranch(bp[bp.length - 1], "branch-dropdown", "checkoutLocalBranch(this)");
}
}
})
示例2: clearBranchElement
.then(function (branchList) {
let count = 0;
clearBranchElement();
//for each branch
for (let i = 0; i < branchList.length; i++) {
console.log("branch name: " + branchList[i].name());
//get simplified name
let bp = branchList[i].name().split("/")[branchList[i].name().split("/").length - 1];
Git.Reference.nameToId(repository, branchList[i].name()).then(function (oid) {
// Use oid
console.log("old id " + oid);
if (branchList[i].isRemote()) {
// for remote branches add oid and branch name to remote branches map
remoteName[bp] = oid;
} else {
//add branch name to the branch list
branchCommit.push(branchList[i]);
console.log(bp + " adding to end of " + oid.tostrS());
if (oid.tostrS() in bname) {
bname[oid.tostrS()].push(branchList[i]);
} else {
bname[oid.tostrS()] = [branchList[i]];
}
}
}, function (err) {
console.log("repo.ts, line 273, could not find referenced branch" + err);
});
if (branchList[i].isRemote()) {
if (localBranches.indexOf(bp) < 0) {
displayBranch(bp, "branch-dropdown", "checkoutRemoteBranch(this)");
}
} else {
localBranches.push(bp);
displayBranch(bp, "branch-dropdown", "checkoutLocalBranch(this)");
}
}
})
示例3: 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]);
}
示例4:
.then(repo => Git.Reference.nameToId(repo, reference))