Ruby &引用;吉特分行——合并<;sha>&引用;通过坚固的libgit2绑定?

Ruby &引用;吉特分行——合并<;sha>&引用;通过坚固的libgit2绑定?,ruby,libgit2,rugged,Ruby,Libgit2,Rugged,有没有办法获得与本机git命令相同的信息 git branch --merged <sha> git分支——合并 通过Ruby的libgit2绑定?git提交所做的是查看每个分支,并检查分支和提交之间的合并基(如果没有合并基,则为头)是否对应于分支之一 如果匹配,则合并;如果他们没有,那就不是了。您可以很容易地在ruby中完成这个循环 repo.branches.each(:local) # look only at local branches .map { |b| tgt

有没有办法获得与本机git命令相同的信息

git branch --merged <sha>
git分支——合并

通过Ruby的libgit2绑定?

git提交所做的是查看每个分支,并检查分支和提交之间的合并基(如果没有合并基,则为头)是否对应于分支之一

如果匹配,则合并;如果他们没有,那就不是了。您可以很容易地在ruby中完成这个循环

repo.branches.each(:local) # look only at local branches
.map { |b|
  tgt = b.resolve.target # look at what the branch is pointing to
  # and check if the target commit is included in the history of HEAD
  merged = repo.merge_base(repo.head.target, tgt) == tgt.oid
  [b.name, merged]
} # this will give a list with the name and whether the branch is merged
.keep_if { |name, merged| merged } # keep only the ones which are merged
.map(&:first) # get the name
您可以有一个
合并的\u列表