サーバーにあるgitリポジトリのローカルブランチのリストをユーザーに送信する必要があるノードAPIサーバーを作成しています。多くの場所で、NodeGitのRepository#getReferenceNamesを使用することが提案されています。これが私が行っていることです。
exports.getBranches = function (req, res) {
NodeGit.Repository.open(config.database).then(function(repo) {
return repo.getReferenceNames(NodeGit.Reference.TYPE.LISTALL);
}).then(function (arrayString) {
res.status(200).json({message: "OK", data: arrayString});
}).catch(function (err) {
res.status(500).json({message: err, data: []});
}).done(function () {
console.log("finish");
});
};
ただし、この関数はすべてのブランチを返します。コマンドラインのようにローカルブランチのみを取得する方法はありgit branch
ますか?